Abstract Class in ConceptDraw 7
Creating an Abstract class and adding it to the left side Library panel:
- Drag a “Utility” class to the screen
- Click Edit Group
- Click on the top title and click Edit Group
- Rename “utility” to “abstract”
- Close the edit group window by clicking little x in top right window
- Copy the shape
- Right click in the left side Library pane and click paste
- Right click the shape and change the Properties to Item Name: Abstract, Item Prompt: Abstract Class
Just an old drafted post that never quite got to be published. I’ve moved on from Concept Draw 7 to Enterprise Architect now.
Originally Drafted: February 27, 2008
Block bzr, hg, git and svn directories
Now that we have standardized on using Bazaar (bzr) on our websites, the control directories are unfortunately forced to be put live and by default are accessible to anyone.
How scary would it be if someone was able to get all your source files? See all those secrets behind the web pages, maybe see that if statement that bypasses authorization or something similar to that.
Before settling down with bzr my company played around with quite a few other systems and so some other systems control directories are at risk of being live, even though they shouldn’t be.
An advantage of having the bzr directories accessible live is easy merging by doing something like:
bzr merge http://www.mysite.com
I didn’t want to lose this functionality on our internal systems so added an “Allow from” statement that allows access to the bzr directories from our office’s IP address. You can add as many of these lines as you would like for however many IP addresses you may be using. I believe you could also use Apache authentication with htpasswd to allow username / password access, but the source control client may not be compatible with HTTP authentication.
If you know which source control client programs are compatible with HTTP usernames / passwords, please leave a comment and let us know. Thanks!
Below is a snippet to add to any Apache 2 config file in order to block access to these source control directories. This snippet is based on code from http://codesnippets.joyent.com/posts/show/1364.
<DirectoryMatch "^/.*/(\.bzr|\.git|\.hg|\.svn)/"> Order Deny,Allow # Allow access from our office so we can easily merge live sites. Allow from 55.55.55.55 Deny from all </DirectoryMatch>
tarring bzr repositories for transfer
tar –exclude=’.bzr/branch/lock/*’ –exclude=’.bzr/branch/lock/held’ –exclude=’.bzr/branch/lock/held/*’ –exclude=’.bzr/branch/lock/held/info’ –exclude=’.bzr/repository/obsolete_packs/’ –exclude=’.bzr/repository/lock/’ -czf .bzrcache.tar.gz .bzr
2008-10-24
I had “bzr pack”‘d up around a 1.8 gig site and it jumped to 3 gigs. Found out .bzr/repository/obsolete_packs/ was holding on to both the current 1.8 gig repository and the old, non-packed 1.8 gig. Modified the tar command to reflect that.
cfhttp and gzip/deflate in IIS (Connection Failure: Status code unavailable)
I enabled gzip/deflate compression in IIS on Friday and everything was great, all our sites appeared to be loading faster, figured we’d save some bandwidth, things were looking up. But then today a co-worker was using a tool that <cfhttp>’s to our live web server to grab some config names for a simple bandwidth reporting utility.
The tool just wouldn’t show anything. I added throwOnError=”true” to the <cfhttp> tag and surely enough the page now threw an error, “Connection Failure: Status code unavailable”.
A quick search and following some blog entries still resulted in the same error message being thrown.
Even attempting to disable deflate compression, as mentioned by Colby in the comments at TalkingTree.com didn’t do anything. Although, perhaps disabling it didn’t work properly, I’m not sure, honestly IIS is not my forte, I’ve always been an Apache guy.
Anyways, I changed the <cfhttp> call to just acept gzip encoding and everything worked great! The final code looked like:
<cfhttp url=”..” throwOnError=”true” charset=”utf-8″>
<cfhttpparam type=”header” name=”Accept-Encoding” value=”gzip” />
<cfhttpparam type=”header” name=”TE” value=”deflate;q=0″>
</cfhttp>
Enabling gzip in Apache 2 / IIS 6
Apache 2, instructions were pretty easy. IIS 6 was a bit tricky. Finally found a great resource at SixFive that had step by step copy/paste instructions. After following that page, gzip was working!
Ext.MessageBox.show(..)
Phew, just was struggling with ExtJS, specifically Ext.MessageBox.show(). I couldn’t get a callback function to execute even using a config such as {fn: myCallback}. Turned out I had to put the fn before the icon config property I was passing.
Strange, but that’s what happened. I haven’t had time to confirm this is consistent behaviour. Just a note for myself.
MySQL Collation and ORDER BY
I was doing a query today and notice that when doing a query such as “SELECT label FROM category ORDER BY label ASC”, I would receive results that looked like:
Bob’s Category
Test
asdf
Notice how “asdf” is below all the rest? This is because the table (and database) had their collation set to utf8_bin, which makes it perform a binary search. Just had to change the MySQL database and table collation to “utf8_general_ci” and the problem was fixed.
Just something to be aware of.
Naming / Coding / Design Standards
I just submitted this to the CFCDev list, but due to formatting issues when posting to the list, have included the same message below…
I am trying to come up with some naming, coding and design standards/conventions. Things that should be followed by me as well as other developers I work with. Each time I think I Have a convention down, I seem to run into some new use-case that changes that convention. Right now I am working on an online store, doing it the “proper” way using UML use cases and all that good stuff first. Making the thing somewhat proper Object Oriented. I really want to get some OO standards down so that new projects can be developed properly and rapidly. I am hoping to get some opinions on the current standard I am thinking of working with and ironing out some uncertanties. Any input would be greatly appreciated!
Problem 1 – Naming Conventions
Current Guidelines:
-
Variables that represent an id are spelt “id”. Lower case like that. This means:
- myObject.getId()
- Table column = id
- This rule is in place because “Identifier” is not 2 words, so why should ID be 2 words?
-
Names that are 3 characters or longer are lower cased.
- URL is url
- XML is xml
-
DAO is dao
- This is where my current problem is, should this be DAO or dao? What looks more natural to you when seeing a CFC name or a class name in a UML diagram: CustomerDao or CustomerDAO?
-
This vs this vs THIS…What would you use?
-
Would you use the same format for all other built-in variable scopes (i.e. Variables, URL, Form, Client, …)
-
- For the DAO, findById() or loadById() or getById() method names? What about findAll()/loadAll()/getAll()Problem 2 – Architecture Conventions
My next problem is more about coming up with a base architecture that can be followed. Right now, this is what I have thought of for the Customer entity in this store:
- Customer
-
CustomerService
- Calculations and other operations go inside here.
-
CustomerDao
- I removed the CustomerGateway in favour of putting everything into the DAO. Perhaps this was a bad idea?
-
CustomerDaoConnector
- This would be where all the actual cfquery tags are. The DAO would call the methods in here to get the query data and then the DAO would convert the query data into an array of objects. I know there is debate out there of whether a DAO should return queries or objects, I feel though that it is best to return Objects because then if something needs to run on the object, such as a composite variable (e.g. Customer.name returns Customer.firstName and Customer.lastName) then it can do so. So for the purpose of this article, just know I want the DAO always returning objects, never queries. The queries should go in CustomerDaoConnector.
-
That said, would CustomerDaoConnector be better named CustomerDaoSource? This comes from the shortened version of CustomerDataSource….although maybe CustomerDataSource would be a better name? What do you think, which 1 of the below sounds best to you, or should these functions just be part of the functions in the Customer DAO?
- CustomerDaoConnector
- CustomerDaoSource
-
CusomerDataSource
-
My only problem with this is that this data source object is going to be fairly tightly coupled to the DAO, since the data source on it’s own shouldn’t be used anywhere else. So when looking at files it’s kind of nice to see CustomerDao and then right below it CustomerDaoConnector. I kind of like the sound of CustomerDataSource though…what do you think? The “Data Source” object name came from the diagram at http://java.sun.com/blueprints/corej2eepatterns/Patterns/images09/figure09_01.gif which was contained in http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html.
-
Before I start building this application I would like to have these conventions down pat. The more input everybody out there has, the better!
Thanks!
Greg
Here is an initial draft of the UML diagram for what I have described above. My UML skills are weak, so hopefully it makes some sense.
Speed Zones
Alright, this is a random thought I had on the commute from work back down to home today. Coming home, the weather was really rainy and visibility was pretty poor. I was slowed down at a playground zone to 30 and I was thinking that I was so busy trying to watch to make sure I stayed under 30 that I wasn’t paying as much attention to the road. I had come from doing about 60 km/h and at that speed I was paying a lot of attention, because I had to. When slowing down to 30, I was distracted by the speedometer and think I was less focused on the road, and thus more of a danger, than I would have been if I had been doing 50 or even 40. Perhaps that’s the answer, raise playground speeds to 40? Either that or maybe I should just learn not to trip about the speedometer, stay slow and focus on the road.
As a new father (going on 5 months once June 5 hits) I have a slightly different opinion. I am sure it will be nice to take Lucas around the park without worrying about some punk coming through going 60 km/h. But 40 km/h, may not be bad. I mean, really, unless it’s prime time (i.e. school opening or closing, lunch) then perhaps 30 km/h isn’t need. Seems most cars go 30 without barely lifting your foot of the gas, almost tempting you to go a little faster than 30 km/h. Maybe even 35 km/h would be okay, with leniance towards people going 40 during off-peak hours.
Man, I don’t know. If anyone is reading this, what do you think?
Using UNION for 1:n relationship
I was just thinking about joining Facebook. I have put it off forever, partly because I don’t necessarily have the time, partly because I used to be more of a loner and not really want to talk to that many people and also partly because I was waiting for it to go away. Well it hasn’t gone away, I do want to stay in touch with people more now and I can make a bit of time. Besides I am an internet applications developer, I should stay in touch with the community and see what is going on out there, what people like to use, what they would like to change, what I like to use, etc… Anyways this led me to thinking about databases.
I signed up once on Facebook with an email address I don’t use that often anymore. I have a couple of friends under that account which I would like to keep, but I would like to be able to register my new address with Facebook. This way if people add me under either my new or old address, they will be able to find me. So I started thinking very simply about database design and relationships. If you had a users table with columns: ID, username [assuming username is your email address], password. Of course there would be other column but simple example here. So what happens if you remove that username column and instead create a new table, user_username with columns: username, fk_user_ID, isPrimary. This would allow a user to have many usernames (a 1-to-many or 1:n relationship). Now if you wanted to retrieve all of a users information, including all usernames, using only 1 query, how would you do it in MySQL?
UNION is how you would do it.
Wouldn’t it be great if you could run a query that would return something like:
ID | username | First Name
1 | bob@mail1.com | Bob
| bob@mail2.com |
See, all you would be doing is retrieving all the initial records for our user Bob, then you would also be populating the result with more records that just contain the rest of Bob’s email address.
My theory of doing this is to do something like:
(
SELECT
user.ID,
user_username.username,
user.firstName
FROM
user
LEFT JOIN
user_username
ON user.ID = user_username.fk_user_ID
AND user_username.isPrimary = 1
WHERE
user.ID = 1
LIMIT 1
)
UNION ALL
(
SELECT
NULL AS ID,
user_username.username,
NULL AS firstName
FROM
user_username
WHERE
user.ID = 1
AND isPrimary = 0
)
Going to have to mock this up later and see what happens.
Leave a Comment
Leave a Comment
Leave a Comment