RE: OOD/Design Patterns and ColdFusion.
Hey there, I'm am further behind than you are...but if I wanted to learn MVC and objects I would do the quick start guide in Model Glue and then build a few really small apps. My understanding is that model glue enforces MVC and OOP. I bet you would understand alot more after a few hours of playing around with Model Glue than after reading a few books. Get the books and read them over time as you play with Model Glue. Mark -Original Message- From: Andy Matthews [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 1:21 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. That doesn't discuss code though. It's just ideas? I tried browsing the book and it didn't work. !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: Massimo Foti [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 12:19 PM To: CF-Talk Subject: Re: OOD/Design Patterns and ColdFusion. This book: http://www.oreilly.com/catalog/hfdesignpat/ ? Get it. You will not regret. There is also an upcoming title from the same series that looks good: http://www.oreilly.com/catalog/hfobjects/ ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240885 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
You know, I gave almost the same question last week on the model-glue mailing list. Kept seeing these real simple samples, but nothing that appeared to work with complex data. Matt Williams was kind enough to whip out a basic application and place the download on his blog (http://mattw.mxdj.com/sample_servicedaobean_files.htm). Although it doesn't use a total bean/DAO/Gateway architecture (see Ray's series on Model-Glue for more info [http://ray.camdenfamily.com/index.cfm/ModelGlue]), Matt's is still a great, and easy to understand, example of how to handle complex data objects. He also built it without using a framework so that anyone can gain from the examples and apply to whatever methodology they are using for their development. Cutter __ http://blog.cutterscrossing.com Steve Brownlee wrote: Ian, I think this project is a perfect place to start since you're only dealing with one object and its data. I'll provide my thoughts and hopefully it will help. One thing I want to say is that you're still performing the steps procedurally, but the data is manipulated as attributes of an object. You are still going to create a form and then submit to a processing page that validates everything. How you build the application remains unchanged. But I can not convert this to an object orientated design. I can create a simple object that would represent a trima machine which I believe is often called a bean You're on the right track here. You create the Trima Bean. It simply holds the attributes and get/set methods for each attribute of a trima machine. Since the bean's function is to accept and give the data while it's being manipulated, the validation should be done at this point. I think I understand how one would separate the database logic into a DAO. Correct, the TrimaDAO handles *all* access to the datasource. This is its only purpose, which is why the data should not be validated here. It has the CRUD methods [create/read/update/delete]. Each of these methods has one argument which accepts a Trima Bean which is a struct. cfargument name=TrimaBean type=struct required=true So a sample call would be: trimaDAO = createobject(component, com.bloodsource.trimaDAO); trimaDAO.update(trimaBean); Is it good or bad to put bad and/or partial data into the bean because some of the form data was good and some was bad? IMHO, since validation is done by the bean, partial data in one of the attributes is not acceptable. How does one use a form first to show the current bean data and then to show the form submitted data with error feedback? FORM PAGE -- cfscript trimaBean = createobject(component, com.bloodsource.trimaBean); trimaDAO = createobject(component, com.bloodsource.trimaDAO); trimaBean.setMachineID(64); currentTrimaBean = trimaDAO.read(trimaBean); /cfscript form action=ProcessTrimaBean.cfm input type=text name=PlateletLevel value=#currentTrimaBean.getPlateletLevel()# input type=text name=BloodType value=#currentTrimaBean.getBloodType()# etc... /form PROCESSING PAGE -- cftry cfscript trimaBean = createobject(component, com.bloodsource.trimaBean); trimaDAO = createobject(component, com.bloodsource.trimaDAO); trimaBean.setPlateletLevel(form.PlateletLevel); trimaBean.setBloodType(form.BloodType); etc... trimaDAO.update(trimaBean); /cfscript cfcatch cfset alertMessage = trimaBean.invalidDataMessage -- DISPLAY ERROR INFORMATION HERE -- /cfcatch cftry ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240733 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
One book I would thoroughly recommend is: Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and the Unified by Craig Larman. There are a number of facets to understand about OO programming such as inheritance/encapsulation etc. But the most difficult aspect of all is identifying the objects you need (assigning responsibilities) in a way which will ensure that moving forward your application is easier to maintain. Don't be put off by the title, the book provides a way of approaching the process of identifying the objects you need and provides an introduction to UML along the way. During the middle it discusses the application of design patterns and it is at this point I think you could do with the Head first book (which is a great book) to supplement your knowledge of them. HTH Kola -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: 16 May 2006 16:46 To: CF-Talk Subject: SOT: OOD/Design Patterns and ColdFusion. I guess I just do not have a natural OOP/OOD/OOA type mind. I get a basic object and its purpose to encapsulate data and functionality. But as soon as I try to start putting objects together to build a system, I quickly get lost in a quagmire. This usually results in my falling back to my procedural experience, peppered with a small object or two, to get the current task done by my deadline. So can anybody point out a good resource or ten on how to actually program with object and patterns. Everything I have found to date seems to be geared on selling the why one should program this way and are very light on the how one actually writes the code. Conversely, if I can pick the minds of this group, maybe somebody can give me some pointers on how one would solve a common web requirement with objects/cfcs. This would be a basic admin task of showing a list of items allowing for the adding and editing of these items with data validation and the storage of the data in a database. I hear terms like beans, DAO's, MVC patterns ect. But I can't figure out how to even start coding all this. I suppose that one could just pick a framework that uses all this. But I would feel much more comfortable with choosing among the growing list of frameworks if I had a clearer understanding of the basics. Thanks in advance. -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - C code. C code run. Run code run. Please! - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~ ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240734 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
The most useful thing I found on Design Patterns was an article on them in CFDJ about 2 years ago. After that all the books started to make sense. They had some code examples for DAO, Gateway, Beans and other objects that were all new to me at that time. seeing the code in CF was great. Now lots of people are writing code like that. Check out the new flex2 Beta3 to which you can add the CF and Actionscript wizards which create DAO and Bean objects from a database using RDS. Read that code as a starting point. Then read the books. The objects create are simple, but it saves a lot of typing. Kevin Roche ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240737 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Headfirst Design Patterns Couldn't agree more... Brilliant book -Original Message- From: Ben Nadel [mailto:[EMAIL PROTECTED] Sent: 16 May 2006 18:06 To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. Ian, I did a trip into the land of OOP and one of the things that I really found useful was the book Headfirst Design Patterns. Its about design patterns, not specifically object oriented programming, but the two have a lot of overlap in programming. It's a very easy to read, well put together book. Ben Nadel Web Developer Nylon Technology 350 7th Avenue Floor 10 New York, NY 10001 212.691.1134 212.691.3477 fax www.nylontechnology.com You know, like nunchuck skills, bowhunting skills, computer hacking skills... Girls only want boyfriends who have great skills. - Napoleon Dynamite -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 12:46 PM To: CF-Talk Subject: SOT: OOD/Design Patterns and ColdFusion. I guess I just do not have a natural OOP/OOD/OOA type mind. I get a basic object and its purpose to encapsulate data and functionality. But as soon as I try to start putting objects together to build a system, I quickly get lost in a quagmire. This usually results in my falling back to my procedural experience, peppered with a small object or two, to get the current task done by my deadline. So can anybody point out a good resource or ten on how to actually program with object and patterns. Everything I have found to date seems to be geared on selling the why one should program this way and are very light on the how one actually writes the code. Conversely, if I can pick the minds of this group, maybe somebody can give me some pointers on how one would solve a common web requirement with objects/cfcs. This would be a basic admin task of showing a list of items allowing for the adding and editing of these items with data validation and the storage of the data in a database. I hear terms like beans, DAO's, MVC patterns ect. But I can't figure out how to even start coding all this. I suppose that one could just pick a framework that uses all this. But I would feel much more comfortable with choosing among the growing list of frameworks if I had a clearer understanding of the basics. Thanks in advance. -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - C code. C code run. Run code run. Please! - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240744 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Great example Steve!! I've been reading along with Ian, letting him ask all the dubmd questions (just kidding Ian), but all the while I've been learning right along with him. Thanks a lot. !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: Steve Brownlee [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 17, 2006 1:55 AM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. Ian, I think this project is a perfect place to start since you're only dealing with one object and its data. I'll provide my thoughts and hopefully it will help. One thing I want to say is that you're still performing the steps procedurally, but the data is manipulated as attributes of an object. You are still going to create a form and then submit to a processing page that validates everything. How you build the application remains unchanged. But I can not convert this to an object orientated design. I can create a simple object that would represent a trima machine which I believe is often called a bean You're on the right track here. You create the Trima Bean. It simply holds the attributes and get/set methods for each attribute of a trima machine. Since the bean's function is to accept and give the data while it's being manipulated, the validation should be done at this point. I think I understand how one would separate the database logic into a DAO. Correct, the TrimaDAO handles *all* access to the datasource. This is its only purpose, which is why the data should not be validated here. It has the CRUD methods [create/read/update/delete]. Each of these methods has one argument which accepts a Trima Bean which is a struct. cfargument name=TrimaBean type=struct required=true So a sample call would be: trimaDAO = createobject(component, com.bloodsource.trimaDAO); trimaDAO.update(trimaBean); Is it good or bad to put bad and/or partial data into the bean because some of the form data was good and some was bad? IMHO, since validation is done by the bean, partial data in one of the attributes is not acceptable. How does one use a form first to show the current bean data and then to show the form submitted data with error feedback? FORM PAGE -- cfscript trimaBean = createobject(component, com.bloodsource.trimaBean); trimaDAO = createobject(component, com.bloodsource.trimaDAO); trimaBean.setMachineID(64); currentTrimaBean = trimaDAO.read(trimaBean); /cfscript form action=ProcessTrimaBean.cfm input type=text name=PlateletLevel value=#currentTrimaBean.getPlateletLevel()# input type=text name=BloodType value=#currentTrimaBean.getBloodType()# etc... /form PROCESSING PAGE -- cftry cfscript trimaBean = createobject(component, com.bloodsource.trimaBean); trimaDAO = createobject(component, com.bloodsource.trimaDAO); trimaBean.setPlateletLevel(form.PlateletLevel); trimaBean.setBloodType(form.BloodType); etc... trimaDAO.update(trimaBean); /cfscript cfcatch cfset alertMessage = trimaBean.invalidDataMessage -- DISPLAY ERROR INFORMATION HERE -- /cfcatch cftry ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240751 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Steve... I do have one comment/question about your example. It seems to be a little excessive to have a get and set method for each individual column in a database. Can you explain the reasoning behind this? !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240752 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Is it good or bad to put bad and/or partial data into the bean because some of the form data was good and some was bad? IMHO, since validation is done by the bean, partial data in one of the attributes is not acceptable. Ok, I might almost have enough of an idea to give a first try at this bean/DAO stuff. But I have a follow up question concerning validation before I start coding. Looking at the person/address example provide in an early post by Matt, I see the validation being in the setter methods of the bean. That was my first instinct. But I am confused by the above statement of since validation is done by the bean, partial data in one of the attributes is not acceptable. Is this not contradictory with the validation of each parameter being done within the individual setter methods. Maybe a simple example can explain my thinking better. FORM ACTION PAGE cftry trimaBean.setID(from.trimaID); trimaBean.setSerialNumber(form.SerialNumber); trimaBean.setInService(form.InService); trimaBean.setOutService(form.OutService); //This call throws an exception, because the Out Service date is before the in service data as an example. /cftry First of all, would this not leave the bean in an incomplete state, it would have the ID, SerialNumber and InService properties set, but not the OutService date. Is this not a bad thing? Now I would also want to go back to the form to allow the user to correct the data, repopulating the form with the submitted data so that only the incorrect datum needs to be fixed. Where do I get the data to repopulate the form, from the bean, which means I would have to store the bad date in the bean to get it back out, or some kind of branching logic in the form display to say sometimes populate the form from a bean, other times from some other data structure? This is the kind of thinking that gets me lost. -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - C code. C code run. Run code run. Please! - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240771 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
1. Validation 2. Encapsulation 3. It just makes so much darned sense, don't it? For many web app developers, classes (or beans in this discussion) are code representations of database objects and so must perform the function of getting data from, or putting data into, those database fields. Keep in mind one of the basic tenets of OOP: encapsulation. Encapsulation is done in the hopes of preventing us silly, little humans from messing up our data by adding more rules and processing than is necessary. If you have one get/set for each attribute, then the code for those methods are ridiculously straightforward and very hard to mess us. If you, however, have one method to accept all attributes in some sort of delimited format, then the rules becoming much more complex and the chance for bugs and bad data increase exponentionally (just a figure of speech, I have no proof that it is exponential). Steve The Boss Brownlee http://www.orbwave.com/cfjboss -Original Message- From: Andy Matthews [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 17, 2006 10:09 AM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. Steve... I do have one comment/question about your example. It seems to be a little excessive to have a get and set method for each individual column in a database. Can you explain the reasoning behind this? !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240772 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
In a set method for address (for example), that doesn't actually update the database does it? It simply changes the value stored in the session var or something? !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: Steve Brownlee [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 17, 2006 11:16 AM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. 1. Validation 2. Encapsulation 3. It just makes so much darned sense, don't it? For many web app developers, classes (or beans in this discussion) are code representations of database objects and so must perform the function of getting data from, or putting data into, those database fields. Keep in mind one of the basic tenets of OOP: encapsulation. Encapsulation is done in the hopes of preventing us silly, little humans from messing up our data by adding more rules and processing than is necessary. If you have one get/set for each attribute, then the code for those methods are ridiculously straightforward and very hard to mess us. If you, however, have one method to accept all attributes in some sort of delimited format, then the rules becoming much more complex and the chance for bugs and bad data increase exponentionally (just a figure of speech, I have no proof that it is exponential). Steve The Boss Brownlee http://www.orbwave.com/cfjboss -Original Message- From: Andy Matthews [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 17, 2006 10:09 AM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. Steve... I do have one comment/question about your example. It seems to be a little excessive to have a get and set method for each individual column in a database. Can you explain the reasoning behind this? !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240776 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
Correct Andy. Calling the set method would only do whatever the code within those cffunction/cffunction tags tells it to. Usually a setAddress( Form.Address) call simply updates the data which is in the variables (or variables.instance) scope of the component (object) the set method is in. To update the database, somewhere in your code you would have to explicitly call the update function of a Data Access Object (DAO). ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240780 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Right...I saw that. Thanks for the clarification. !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: Matt Williams [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 17, 2006 12:20 PM To: CF-Talk Subject: Re: OOD/Design Patterns and ColdFusion. Correct Andy. Calling the set method would only do whatever the code within those cffunction/cffunction tags tells it to. Usually a setAddress( Form.Address) call simply updates the data which is in the variables (or variables.instance) scope of the component (object) the set method is in. To update the database, somewhere in your code you would have to explicitly call the update function of a Data Access Object (DAO). ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240781 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
The set method for address would typically 'set' the variable within the instance of the bean. The 'update' or 'create' methods are generally called from within a service layer or gateway, which in turn converts any data as necessary, populates a bean instance, validates that instance, and then runs the respective method from the DAO to actually populate or update the db. A word on validation. Say you have a method to 'set' an email address (or phone number, or social security number). Your 'set' method will be very simple, populating the variable within the bean instance only, while varifying it to be of the proper variable type (string, numeric, etc.) by using the 'type' attribute of cfargument. The validate() function of a bean is kind of a pre-processing function, used to do things like server side validation of an email address, or remove dashes from a phone number while insuring that it's the correct length. Verifying that all vars contain an accepted value for those db fields that don't allow nulls. Cutter _ http://blog.cutterscrossing.com Andy Matthews wrote: In a set method for address (for example), that doesn't actually update the database does it? It simply changes the value stored in the session var or something? !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: Steve Brownlee [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 17, 2006 11:16 AM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. 1. Validation 2. Encapsulation 3. It just makes so much darned sense, don't it? For many web app developers, classes (or beans in this discussion) are code representations of database objects and so must perform the function of getting data from, or putting data into, those database fields. Keep in mind one of the basic tenets of OOP: encapsulation. Encapsulation is done in the hopes of preventing us silly, little humans from messing up our data by adding more rules and processing than is necessary. If you have one get/set for each attribute, then the code for those methods are ridiculously straightforward and very hard to mess us. If you, however, have one method to accept all attributes in some sort of delimited format, then the rules becoming much more complex and the chance for bugs and bad data increase exponentionally (just a figure of speech, I have no proof that it is exponential). Steve The Boss Brownlee http://www.orbwave.com/cfjboss -Original Message- From: Andy Matthews [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 17, 2006 10:09 AM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. Steve... I do have one comment/question about your example. It seems to be a little excessive to have a get and set method for each individual column in a database. Can you explain the reasoning behind this? !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240784 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
The bean in the example I did was actually generated by the RDS plugin of Eclipse. The only validation there is making sure the correct data type is being received (e.g., a number and not a string). The type of validation you are speaking of require some actual cfif's. I would not put that validation in the setter methods, but rather a separate Validation method that can go into the bean. This way, your cftry around the setters will throw an error if you have bad data types. You could probably handle that by redirecting to the form and populating the form based on what is in the bean. If a particular setter threw an error your getter call should return whatever the default value is. If you don't get an error on any of your setters, then you could run the Validation method that makes sure certain dates make sense, etc. Your validation method could return some sort of message so that you know whether it was all good, or something was bad. If it was bad, you would redirect to the form, populate the form based on the bean's data, and display the message pointing out the invalid data. Hope that helps. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240788 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
First of all, would this not leave the bean in an incomplete state, it would have the ID, SerialNumber and InService properties set, but not the OutService date. Is this not a bad thing? It's not inheritly bad that some attributes get set and others don't, but to prevent some valid data not making it into the bean, you could try a different process. Just some code off the top of my head... trimaBean.setID(from.trimaID); trimaBean.setSerialNumber(form.SerialNumber); trimaBean.setInService(form.InService); trimaBean.setOutService(form.OutService); if ( arrayLen(trimaBean.invalidData) gt 0 ) // throw an error here, or display an error on the page // and stop processing more rules So in every set method, if there was an error, you add the message/code to the invalidData array, and when you're all done calling the set methods, check to see if any were invalid. You wouldn't need to branch the code, or store bad data, that's the whole point. Bad data never makes it into the bean. The attribute would remain blank/0 until valid data was entered. Then you would simply repopulate the form with the bean data which would leave invalid fields blank with a message on the screen explaining to the user which ones he/she needs to fill again. Steve The Boss Brownlee http://www.orbwave.com/cfjboss ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240793 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Matt Williams Yes, this thread has been most helpful. Let me see if I understand your message correctly and follow up with a few more questions. So my basic bean for a Trima Machine would have the five properties, TrimaID, SerialNumber, Version, InServiceDate, OutServiceDate with matching setter and getter methods for each one. The setter methods would only do basic data type validation. Then there would also be a Validate method that would look at the overall data and validate that it is correct, such as OutServiceDate comes after InServiceDate. Then my action page flow would be something like this. Set each form field to appropriate bean property with matching setter method. If no errors are thrown, call Validate method and then either request correction(s) by the user or call the DAO to insert/update the database and move on. My big question is how does this play with object reuse? Five months form now a new developer comes along and creates some new app that for some reason may modify Trima data. They do not realize that they should run the validate method, and go straight from setting the properties to running the DAO and thus inserting bad data into database. Reading the first chapters of a couple of the books suggested in this thread has indocterned me in the concept that on object is supposed to be responsible for its own action and data. It seems somewhat counter to this concept to expect all future users of the TrimaBean object to call a Validate method before running any DAO operations. Am I over complicating things here? -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - C code. C code run. Run code run. Please! - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240795 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
They do not realize that they should run the validate method The validate method for each attribute would be an internal method, not invoked from the caller page. cffunction name=setSerialNumber ... cfargument name=serialNumber type=number ... // Validate argument type // Validate argument data // Set attribute to argument value // or // Throw validation error /cffunction ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240797 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
They do not realize that they should run the validate method The validate method for each attribute would be an internal method, not invoked from the caller page. cffunction name=setSerialNumber ... cfargument name=serialNumber type=number ... // Validate argument type // Validate argument data // Set attribute to argument value // or // Throw validation error /cffunction Ok this was my first thought as well, but then how does one incorporate this if the validation requires checking a relationship between two properties, such as BeginDate is always before EndDate. When would you run this? Since one would need both dates set before any sensible validation could be checked, wouldn't one? -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - C code. C code run. Run code run. Please! - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240798 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
When validating the start date, you would check to see if the endDate was blank. If it is blank, the start date is valid. If enddate is not blank, then check the relationship (startdate less than enddate) You'd do the same blank/relationship check for the enddate On 5/17/06, Ian Skinner [EMAIL PROTECTED] wrote: Ok this was my first thought as well, but then how does one incorporate this if the validation requires checking a relationship between two properties, such as BeginDate is always before EndDate. When would you run this? Since one would need both dates set before any sensible validation could be checked, wouldn't one? ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240801 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
cffunction name=validateBeginDate cfif variables.endDate neq // make sure begin is before end /cfif /cffunction cffunction name=validateEndDate cfif variables.beginDate neq // make sure end is after begin /cfif /cffunction cffunction name=setBeginDate ... cfset isValid = validateBeginDate() ... /cffunction cffunction name=setEndDate ... cfset isValid = validateEndDate() ... /cffunction That way the order in which they are set is moot. The equivalent of an XOR operation :) -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 17, 2006 2:41 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. They do not realize that they should run the validate method The validate method for each attribute would be an internal method, not invoked from the caller page. cffunction name=setSerialNumber ... cfargument name=serialNumber type=number ... // Validate argument type // Validate argument data // Set attribute to argument value // or // Throw validation error /cffunction Ok this was my first thought as well, but then how does one incorporate this if the validation requires checking a relationship between two properties, such as BeginDate is always before EndDate. When would you run this? Since one would need both dates set before any sensible validation could be checked, wouldn't one? ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240802 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
Here you are seeing that there are a multitude of ways to accomplish the same task. Steve mentions that you could call the validate with in the setter method. I have done just that for something simple like stripping out dashes from a phone and/or fax number. I'm not sure that it makes sense for your date comparison need because it would be a toss up between which of the dates you should make the call in. But it would work. Another way to approach the bean is instead of calling each setter from outside the bean, you pass all the data into the init function. The init function would the have a call to each setter. It could also have a call to the Validate method. There is another code generator that makes beans this way. The good Peter Farrell wrote it and it is on his website. If you want to check it out, verify and copy the data below TrimaID numeric SerialNumber numeric (or maybe it is a string) Version numeric InServiceDate date OutServiceDate date Go to rooibos.maestropublishing.com and paste that into the Bean template box. Enter a name for your bean and path (both are optional) and click the Execute button. You can look at the init function to see what I'm talking about. Peter also has some options that you may be interested in concerning validation. Regarding your concern that another developer wouldn't know about running the Validation method. Two thoughts: maybe they should know to do this. Or maybe they should only be accessing your UpdateTrima function in your TrimaService CFC which does the validation for you. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240804 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Steve Brownlee That way the order in which they are set is moot. The equivalent of an XOR operation :) Ok that makes sense and seems to align well with the concept of the bean/object being responsible for itself. I think I got a handle on the form, form action, bean and dao relationship. Writing up some code not to see how it goes. I'm sure I'll be back for more questions when I get into the actual implementation. One question that has not yet been addressed is how would I use these bean and DAO objects for the master page? Or is it easier just to keep this procedural where I would query the database for all the Trima Records and output each one with a link to the form-detail page? -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - C code. C code run. Run code run. Please! - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240812 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
If your not going to use a gateway Object, I would put a method in your DAO to return a query for the master list. You could then create a bean and populate it though each record or just output the query. I tend to do a bit of both so I guess my apps are more OOish the straight OO. If your going to use a gateway CFC, the gateway holds all the methods the would return more than one row, as these cannot be returned to the caller in a bean. -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 17, 2006 4:16 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. Steve Brownlee That way the order in which they are set is moot. The equivalent of an XOR operation :) Ok that makes sense and seems to align well with the concept of the bean/object being responsible for itself. I think I got a handle on the form, form action, bean and dao relationship. Writing up some code not to see how it goes. I'm sure I'll be back for more questions when I get into the actual implementation. One question that has not yet been addressed is how would I use these bean and DAO objects for the master page? Or is it easier just to keep this procedural where I would query the database for all the Trima Records and output each one with a link to the form-detail page? -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - C code. C code run. Run code run. Please! - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240814 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
One question that has not yet been addressed is how would I use these bean and DAO objects for the master page? Or is it easier just to keep this procedural where I would query the database for all the Trima Records and output each one with a link to the form-detail page? Now you are talking about a Gateway object. While the DAO deals with one record at a time, the gateway object is responsible for many records. I typically never want all records from a table. Instead the user will have entered some search criteria. For example: cffunction name=SearchRecords cfarguments name=SearchCriteria type=struct cfquery name=qGetTrimas datasource=#variables.dsn# SELECT * FROM Trimas WHERE 1=1 cfif StructKeyExists(arguments.SearchCriteria.SerialNumber) AND SerialNumber LIKE cfqueryparam value=#arguments.SearchCriteria.SerialNumber#% /cfif !--- ditto for other fields that are potential search fields --- /cfquery /cffunction ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240816 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
Oh yeah, I forgot the cfreturn qGetTrimas line. Then you just loop over that query in your output page, adding the links to the detail form. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240817 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
And by gateway object, we're talking about, basically, an abstraction layer on top of the bean and DAO to handle meta functions that cannot be handled by the DAO or Bean individually. It's up to you if you want to tackle that layer now or just stick to a CFQUERY at the top of the page and output all the links and deal with Beans on later pages. -Original Message- From: Trevor Holm-Laursen [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 17, 2006 3:27 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. If your not going to use a gateway Object, I would put a method in your DAO to return a query for the master list. You could then create a bean and populate it though each record or just output the query. I tend to do a bit of both so I guess my apps are more OOish the straight OO. If your going to use a gateway CFC, the gateway holds all the methods the would return more than one row, as these cannot be returned to the caller in a bean. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240818 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
If your not going to use a gateway Object, I would put a method in your DAO to return a query for the master list. You could then create a bean and populate it though each record or just output the query. I tend to do a bit of both so I guess my apps are more OOish the straight OO. If your going to use a gateway CFC, the gateway holds all the methods the would return more than one row, as these cannot be returned to the caller in a bean. Ok, sounds good. Can someone explain a little more on what a Gateway would be; what its purpose, a basic pseudo code example of how one might be constructed and used? Or a good link to a resource that would help with this? I've heard of Gateways many times in my reading, but have yet to see a clear example of one. -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - C code. C code run. Run code run. Please! - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240820 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
I'm building my bean. Created section for the default values modeled on Matt's person/address example. Any concerns on what the default values actually are? Since CF does not have the null. What about a default date for a date parameter or a default Boolean of that type of parameter? What bout zero for a numeric property of zero is a legitimate value for the parameter of this type of object? See how quickly I can come up with mind boogoling concerns! -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - C code. C code run. Run code run. Please! - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240822 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Numeric attributes default to 0, all other simple values default to including dates. -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 17, 2006 3:51 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. I'm building my bean. Created section for the default values modeled on Matt's person/address example. Any concerns on what the default values actually are? Since CF does not have the null. What about a default date for a date parameter or a default Boolean of that type of parameter? What bout zero for a numeric property of zero is a legitimate value for the parameter of this type of object? See how quickly I can come up with mind boogoling concerns! ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240824 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Oh, except boolean values should to either what their default value is in the database or whatever makes sense. -Original Message- From: Steve Brownlee [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 17, 2006 3:57 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. Numeric attributes default to 0, all other simple values default to including dates. -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 17, 2006 3:51 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. I'm building my bean. Created section for the default values modeled on Matt's person/address example. Any concerns on what the default values actually are? Since CF does not have the null. What about a default date for a date parameter or a default Boolean of that type of parameter? What bout zero for a numeric property of zero is a legitimate value for the parameter of this type of object? See how quickly I can come up with mind boogoling concerns! ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240827 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
A Gateway object (of the J2EE pattern table data gateway) is another database abstraction. Where a DAO deals with individual objects/recrods, a Gateway deals with sets of records. In other words, a Gateway will return query result sets. So where a DAO will have methods like create(), read(), update(), delete(), or save() that deal with a single entity, a Gateway might have methods like getAllEmployees(), getCustomersForState(), getOpenOrders(), etc. Here is a relevant blog post: http://geekswithblogs.net/flanakin/archive/2004/03/08/2633.aspx On 5/17/06, Ian Skinner [EMAIL PROTECTED] wrote: If your not going to use a gateway Object, I would put a method in your DAO to return a query for the master list. You could then create a bean and populate it though each record or just output the query. I tend to do a bit of both so I guess my apps are more OOish the straight OO. If your going to use a gateway CFC, the gateway holds all the methods the would return more than one row, as these cannot be returned to the caller in a bean. Ok, sounds good. Can someone explain a little more on what a Gateway would be; what its purpose, a basic pseudo code example of how one might be constructed and used? Or a good link to a resource that would help with this? I've heard of Gateways many times in my reading, but have yet to see a clear example of one. -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240829 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
My best attempt at a skeleton gateway for your TrimaDAO... cfcomponent name=TrimaGateway cffunction name=init returntype=any cfset variables.trimaMachines = ArrayNew(1) /cffunction cffunction name=getAllTrimaMachines returntype=array cfquery name=q_allTrimaMachines select all of your trima machines /cfquery cfscript for ( i=1; i lte q_allTrimaMachines; i=i+1 ) { trimaBean = createobject(component, com.bloodsource.trimaBean); trimaBean.setID( q_allTrimaMachines['id'][i] ); trimaBean.setSerialNumber( q_allTrimaMachines['serialNumber'][i] ); trimaBean.setInService( q_allTrimaMachines['inService'][i] ); trimaBean.setOutService( q_allTrimaMachines['outService'][i] ); ArrayAppend(variables.trimaMachines, trimaBean); } cfscript cfreturn variables.trimaMachines /cffunction /cfcomponent Master Page --- cfset TrimaGateway = createObject(component, com.bloodsource.TrimaGateway).init() cfset allMachines = TrimaGateway.getAllTrimaMachines() // Now loop through the array of trimaBeans and output the data you need -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 17, 2006 3:32 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. If your not going to use a gateway Object, I would put a method in your DAO to return a query for the master list. You could then create a bean and populate it though each record or just output the query. I tend to do a bit of both so I guess my apps are more OOish the straight OO. If your going to use a gateway CFC, the gateway holds all the methods the would return more than one row, as these cannot be returned to the caller in a bean. Ok, sounds good. Can someone explain a little more on what a Gateway would be; what its purpose, a basic pseudo code example of how one might be constructed and used? Or a good link to a resource that would help with this? I've heard of Gateways many times in my reading, but have yet to see a clear example of one. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240831 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Steve Brownlee My best attempt at a skeleton gateway for your TrimaDAO... Thanks, that looks very helpful. I am still playing with the basic bean and DAO, should get to the gateway part shortly. If I understand your example correctly, the gateway supplants the dao when one is working with multiple beans. If true, that clarifies a big confusion for me, where I was trying to imagine a gateway using the DAO object somehow to create multiple beans or something. It was not getting me very far. SO for a simple master - detail - add-update piece of an application. One would probably have a bean.cfc that describes the basic concrete object. A DAO for crud options with the bean data and a database, and a separate gateway type object when one wants to read multiple beans from the database. I presume one would not often, if ever, use a gateway for insert and/or update operations since one very seldom does that against multiple rows. -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - C code. C code run. Run code run. Please! - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240833 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
CF already has an idiom for dealing with recordsets: the query result set. There is significant overhead of building an array of CFC instances for all the matching records. In just about every context I've ever encountered, this is overkill. I would recommend simply returning the query result set. Indeed, this is how Reactor, ObjectBreeze, and the other ORM frameworks and code generators handle gateway objects. So to modify the example, I would simply do: cfcomponent name=TrimaGateway cffunction name=init returntype=any cfreturn this / /cffunction cffunction name=getAllTrimaMachines returntype=query cfquery name=q_allTrimaMachines select all of your trima machines /cfquery cfreturn q_allTrimaMachines /cffunction /cfcomponent On 5/17/06, Steve Brownlee [EMAIL PROTECTED] wrote: My best attempt at a skeleton gateway for your TrimaDAO... cfcomponent name=TrimaGateway cffunction name=init returntype=any cfset variables.trimaMachines = ArrayNew(1) /cffunction cffunction name=getAllTrimaMachines returntype=array cfquery name=q_allTrimaMachines select all of your trima machines /cfquery cfscript for ( i=1; i lte q_allTrimaMachines; i=i+1 ) { trimaBean = createobject(component, com.bloodsource.trimaBean); trimaBean.setID( q_allTrimaMachines['id'][i] ); trimaBean.setSerialNumber( q_allTrimaMachines['serialNumber'][i] ); trimaBean.setInService( q_allTrimaMachines['inService'][i] ); trimaBean.setOutService( q_allTrimaMachines['outService'][i] ); ArrayAppend(variables.trimaMachines, trimaBean); } cfscript cfreturn variables.trimaMachines /cffunction /cfcomponent Master Page --- cfset TrimaGateway = createObject(component, com.bloodsource.TrimaGateway).init() cfset allMachines = TrimaGateway.getAllTrimaMachines() // Now loop through the array of trimaBeans and output the data you need -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 17, 2006 3:32 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. If your not going to use a gateway Object, I would put a method in your DAO to return a query for the master list. You could then create a bean and populate it though each record or just output the query. I tend to do a bit of both so I guess my apps are more OOish the straight OO. If your going to use a gateway CFC, the gateway holds all the methods the would return more than one row, as these cannot be returned to the caller in a bean. Ok, sounds good. Can someone explain a little more on what a Gateway would be; what its purpose, a basic pseudo code example of how one might be constructed and used? Or a good link to a resource that would help with this? I've heard of Gateways many times in my reading, but have yet to see a clear example of one. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240834 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
The if ever is true. The Gateway manipulates recordsets for you. The DAO still performs all operations on individual rows. You could, of course, write a gateway function that performs mass updates/insertions, but it would still be looping over a structure/array and using the DAO to perform the operations. That's another long discussion altogether and some people would argue against doing that. Steve The Boss Brownlee http://www.orbwave.com/cfjboss -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 17, 2006 4:47 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. Steve Brownlee My best attempt at a skeleton gateway for your TrimaDAO... Thanks, that looks very helpful. I am still playing with the basic bean and DAO, should get to the gateway part shortly. If I understand your example correctly, the gateway supplants the dao when one is working with multiple beans. If true, that clarifies a big confusion for me, where I was trying to imagine a gateway using the DAO object somehow to create multiple beans or something. It was not getting me very far. SO for a simple master - detail - add-update piece of an application. One would probably have a bean.cfc that describes the basic concrete object. A DAO for crud options with the bean data and a database, and a separate gateway type object when one wants to read multiple beans from the database. I presume one would not often, if ever, use a gateway for insert and/or update operations since one very seldom does that against multiple rows. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240835 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
On 5/17/06, Steve Brownlee [EMAIL PROTECTED] wrote: 1. Validation That's fine for atomic validation (specific validation rules for this particular field) but you'll still need a way to validate the state of the entire object -- relationships and dependencies between attributes. And since you're going to validate the object later in your scenario, why make it harder by putting validation in each setter and an overal method? All of the code you suggested to handle validation errors in individual setters is simplified by putting it all in a single validate method. PotatO, PotAto I guess ;) 2. Encapsulation This is just plain wrong. What exactly are you encapsulating? You're actually _exposing_ more about the object (such as the specific get/set data types) that will make it *harder* to change your implementation. See this reference for example for a classic why accessors are bad discussion. http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html 3. It just makes so much darned sense, don't it? No, it doesn't in a lot of cases. Especially in a weakly-typed language like ColdFusion or for objects that simply wrap a single database table. Not to pound directly on Steve since this slavish devotion to the DAO pattern comes up every time someone asks about basic db-oriented OO on the list. The DAO pattern is one of _many_ ways to model data objects. There's a whole lot more, some of these http://martinfowler.com/eaaCatalog/ for example. The DAO pattern for J2EE can be seen here http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html is all that _really_ necessary in this instance? Nothing so far points to that. OO is about more than DAO, beans, and getter/setters. In the Java world, you are almost always using a ORM like Hibernate or some JDO tool (or annotations in Java 5) to handle the infrastructure of the objects and the mapping to the database so you can focus on how the objects work together instead of writing lots of fairly tedious code. I think that in this specific instance, an ActiveRecord pattern makes far more sense. I'd suggest grabbing Joe Rinehart's Arf! and using it to handle the _very_ simple objects involved in this scenario as a starting point. Remember the goal is to create the objects in your software model that capture the essence of the object, it's behavior, and relationships. ActiveRecord is a great way to handle CRUD for an object that maps directly to a database table. But change the context and the approach changes -- need to count how many of the 10k rows of the table were put in service after a certain date? Slavish devotion to the DAO pattern gives you an collection (eg array) or 10,000 individual objects and an iterator that you iterate over with individual date comparions for each object Looking at the situation and the context you might choose the RecordSet pattern. Or the Query pattern and solve the problem in a much cleaner way. I'd recommend HF Design Patterns as well to get a good starting point on the whole patterns thing. And Thinking in Patterns. And your choice of a UML book. But as Dave Watts mentioned, the fundamental modeling process is similar to database modeling with the big addition of _behavior_, unless we're only talking about beans in which case it's pretty much identical. -- John Paul Ashenfelter CTO/Transitionpoint (blog) http://www.ashenfelter.com (email) [EMAIL PROTECTED] ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240836 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
John: This thread was simply to help Ian (and any others interested) get an understanding of this model. No one said this was the best way to go, or even said it was necessary. I think you assumed far too much. However, thanks for pointing out why some of these concepts are not a one size fits all way of thinking. As is said many times on this list: whatever works for you, do it. Steve The Boss Brownlee http://www.orbwave.com/cfjboss ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240838 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
On 5/17/06, Brian Kotek [EMAIL PROTECTED] wrote: CF already has an idiom for dealing with recordsets: the query result set. Which is itself a design pattern :) There is significant overhead of building an array of CFC instances for all the matching records. In just about every context I've ever encountered, this is overkill. I would recommend simply returning the query result set. Indeed, this is how Reactor, ObjectBreeze, and the other ORM frameworks and code generators handle gateway objects. As do many of those in other languages (eg ActiveRecord in Rails, Hibernate). Frankly, you can overflow the Java heap if you create too many instances of an object in a collection that could be replaced with a single large resultset object. I mean a LOT of instances though -- I've seen 80k rows come back from a search that were each turned into individual object instances. Ouch! That resulted in an overflow unless the (tomcat in this case) JVM Heap was over 256MB ;) -- John Paul Ashenfelter CTO/Transitionpoint (blog) http://www.ashenfelter.com (email) [EMAIL PROTECTED] ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240839 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Thanks for the question Ian. I'm working on a 20k project in which I'd LOVE to incorporate the things you've mentioned. I'm listening intently. !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 11:46 AM To: CF-Talk Subject: SOT: OOD/Design Patterns and ColdFusion. So can anybody point out a good resource or ten on how to actually program with object and patterns. Everything I have found to date seems to be geared on selling the why one should program this way and are very light on the how one actually writes the code. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240663 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Ian, I did a trip into the land of OOP and one of the things that I really found useful was the book Headfirst Design Patterns. Its about design patterns, not specifically object oriented programming, but the two have a lot of overlap in programming. It's a very easy to read, well put together book. ... Ben Nadel Web Developer Nylon Technology 350 7th Avenue Floor 10 New York, NY 10001 212.691.1134 212.691.3477 fax www.nylontechnology.com You know, like nunchuck skills, bowhunting skills, computer hacking skills... Girls only want boyfriends who have great skills. - Napoleon Dynamite -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 12:46 PM To: CF-Talk Subject: SOT: OOD/Design Patterns and ColdFusion. I guess I just do not have a natural OOP/OOD/OOA type mind. I get a basic object and its purpose to encapsulate data and functionality. But as soon as I try to start putting objects together to build a system, I quickly get lost in a quagmire. This usually results in my falling back to my procedural experience, peppered with a small object or two, to get the current task done by my deadline. So can anybody point out a good resource or ten on how to actually program with object and patterns. Everything I have found to date seems to be geared on selling the why one should program this way and are very light on the how one actually writes the code. Conversely, if I can pick the minds of this group, maybe somebody can give me some pointers on how one would solve a common web requirement with objects/cfcs. This would be a basic admin task of showing a list of items allowing for the adding and editing of these items with data validation and the storage of the data in a database. I hear terms like beans, DAO's, MVC patterns ect. But I can't figure out how to even start coding all this. I suppose that one could just pick a framework that uses all this. But I would feel much more comfortable with choosing among the growing list of frameworks if I had a clearer understanding of the basics. Thanks in advance. -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - C code. C code run. Run code run. Please! - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240664 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
This book? !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: Ben Nadel [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 12:06 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. Ian, I did a trip into the land of OOP and one of the things that I really found useful was the book Headfirst Design Patterns. Its about design patterns, not specifically object oriented programming, but the two have a lot of overlap in programming. It's a very easy to read, well put together book. Ben Nadel Web Developer Nylon Technology 350 7th Avenue Floor 10 New York, NY 10001 212.691.1134 212.691.3477 fax www.nylontechnology.com You know, like nunchuck skills, bowhunting skills, computer hacking skills... Girls only want boyfriends who have great skills. - Napoleon Dynamite -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 12:46 PM To: CF-Talk Subject: SOT: OOD/Design Patterns and ColdFusion. I guess I just do not have a natural OOP/OOD/OOA type mind. I get a basic object and its purpose to encapsulate data and functionality. But as soon as I try to start putting objects together to build a system, I quickly get lost in a quagmire. This usually results in my falling back to my procedural experience, peppered with a small object or two, to get the current task done by my deadline. So can anybody point out a good resource or ten on how to actually program with object and patterns. Everything I have found to date seems to be geared on selling the why one should program this way and are very light on the how one actually writes the code. Conversely, if I can pick the minds of this group, maybe somebody can give me some pointers on how one would solve a common web requirement with objects/cfcs. This would be a basic admin task of showing a list of items allowing for the adding and editing of these items with data validation and the storage of the data in a database. I hear terms like beans, DAO's, MVC patterns ect. But I can't figure out how to even start coding all this. I suppose that one could just pick a framework that uses all this. But I would feel much more comfortable with choosing among the growing list of frameworks if I had a clearer understanding of the basics. Thanks in advance. -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - C code. C code run. Run code run. Please! - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240665 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Ooops... This book: http://www.oreilly.com/catalog/hfdesignpat/ ? !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: Ben Nadel [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 12:06 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. Ian, I did a trip into the land of OOP and one of the things that I really found useful was the book Headfirst Design Patterns. Its about design patterns, not specifically object oriented programming, but the two have a lot of overlap in programming. It's a very easy to read, well put together book. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240666 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
This book: http://www.oreilly.com/catalog/hfdesignpat/ ? Get it. You will not regret. There is also an upcoming title from the same series that looks good: http://www.oreilly.com/catalog/hfobjects/ Massimo Foti Tools for ColdFusion and Dreamweaver developers: http://www.massimocorner.com ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240668 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
That doesn't discuss code though. It's just ideas? I tried browsing the book and it didn't work. !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: Massimo Foti [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 12:19 PM To: CF-Talk Subject: Re: OOD/Design Patterns and ColdFusion. This book: http://www.oreilly.com/catalog/hfdesignpat/ ? Get it. You will not regret. There is also an upcoming title from the same series that looks good: http://www.oreilly.com/catalog/hfobjects/ ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240670 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
Heh - this has prolly been mentioned before, but the girl on this cover must be leading a double life http://tinyurl.com/89lue :) Andy Matthews wrote: Ooops... This book: http://www.oreilly.com/catalog/hfdesignpat/ ? !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: Ben Nadel [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 12:06 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. Ian, I did a trip into the land of OOP and one of the things that I really found useful was the book Headfirst Design Patterns. Its about design patterns, not specifically object oriented programming, but the two have a lot of overlap in programming. It's a very easy to read, well put together book. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240669 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Go down to the sample chapter in pdf. -Original Message- From: Andy Matthews [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 12:21 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. That doesn't discuss code though. It's just ideas? I tried browsing the book and it didn't work. !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: Massimo Foti [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 12:19 PM To: CF-Talk Subject: Re: OOD/Design Patterns and ColdFusion. This book: http://www.oreilly.com/catalog/hfdesignpat/ ? Get it. You will not regret. There is also an upcoming title from the same series that looks good: http://www.oreilly.com/catalog/hfobjects/ ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240671 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Yeah, great book! Really does a good job of walking you through the complicated world of Design Patters. ... Ben Nadel Web Developer Nylon Technology 350 7th Avenue Floor 10 New York, NY 10001 212.691.1134 212.691.3477 fax www.nylontechnology.com You know, like nunchuck skills, bowhunting skills, computer hacking skills... Girls only want boyfriends who have great skills. - Napoleon Dynamite -Original Message- From: Andy Matthews [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 1:13 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. Ooops... This book: http://www.oreilly.com/catalog/hfdesignpat/ ? !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: Ben Nadel [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 12:06 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. Ian, I did a trip into the land of OOP and one of the things that I really found useful was the book Headfirst Design Patterns. Its about design patterns, not specifically object oriented programming, but the two have a lot of overlap in programming. It's a very easy to read, well put together book. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240672 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Andy, The book has java code examples, but easy to translate over to CF. And the ideas themselves are pretty interesting, worth a read. ... Ben Nadel Web Developer Nylon Technology 350 7th Avenue Floor 10 New York, NY 10001 212.691.1134 212.691.3477 fax www.nylontechnology.com You know, like nunchuck skills, bowhunting skills, computer hacking skills... Girls only want boyfriends who have great skills. - Napoleon Dynamite -Original Message- From: Andy Matthews [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 1:21 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. That doesn't discuss code though. It's just ideas? I tried browsing the book and it didn't work. !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: Massimo Foti [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 12:19 PM To: CF-Talk Subject: Re: OOD/Design Patterns and ColdFusion. This book: http://www.oreilly.com/catalog/hfdesignpat/ ? Get it. You will not regret. There is also an upcoming title from the same series that looks good: http://www.oreilly.com/catalog/hfobjects/ ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240673 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
This link was also a very good read. http://www.theserverside.com/news/thread.tss?thread_id=38047 I didn't exactly feel better after reading it (about my OOP skills), but it was great to see the two different sides to theory. ... Ben Nadel Web Developer Nylon Technology 350 7th Avenue Floor 10 New York, NY 10001 212.691.1134 212.691.3477 fax www.nylontechnology.com You know, like nunchuck skills, bowhunting skills, computer hacking skills... Girls only want boyfriends who have great skills. - Napoleon Dynamite ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240674 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
Aw man, that's gonna get flagged in my corporate firewall logs for sure! -Joe On 5/16/06, Crow T. Robot [EMAIL PROTECTED] wrote: Heh - this has prolly been mentioned before, but the girl on this cover must be leading a double life http://tinyurl.com/89lue :) Andy Matthews wrote: Ooops... This book: http://www.oreilly.com/catalog/hfdesignpat/ ? !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: Ben Nadel [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 12:06 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. Ian, I did a trip into the land of OOP and one of the things that I really found useful was the book Headfirst Design Patterns. Its about design patterns, not specifically object oriented programming, but the two have a lot of overlap in programming. It's a very easy to read, well put together book. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240675 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
If you want to start simple, forget all those acronyms, forget design patterns, forget activity diagrams. You want to learn the very basics of what objects are and what they can do for you. You also won't understand the conceptual books without practicing some real code. My suggestion would be to learn some basics of another language that is written to take advantage of OOP. As you know, ColdFusion isn't, and there aren't good books that show you how to think that way via code in ColdFusion. One thing I had a friend do recently was download Microsoft C# Express and gave him my O'Reilly C# book (http://www.oreilly.com/catalog/progcsharp2/) and had him focus on the chapters involving the canons of OOP. Within two weeks, he had finished all of the code tutorials, tried some things on his own and had a basuic, yet solid, understanding of OOP. Without writing real code, you won't gain a true understanding of the subtleties. Steve The Boss Brownlee http://www.orbwave.com/cfjboss -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 12:46 PM To: CF-Talk Subject: SOT: OOD/Design Patterns and ColdFusion. I guess I just do not have a natural OOP/OOD/OOA type mind. I get a basic object and its purpose to encapsulate data and functionality. But as soon as I try to start putting objects together to build a system, I quickly get lost in a quagmire. This usually results in my falling back to my procedural experience, peppered with a small object or two, to get the current task done by my deadline. So can anybody point out a good resource or ten on how to actually program with object and patterns. Everything I have found to date seems to be geared on selling the why one should program this way and are very light on the how one actually writes the code. Conversely, if I can pick the minds of this group, maybe somebody can give me some pointers on how one would solve a common web requirement with objects/cfcs. This would be a basic admin task of showing a list of items allowing for the adding and editing of these items with data validation and the storage of the data in a database. I hear terms like beans, DAO's, MVC patterns ect. But I can't figure out how to even start coding all this. I suppose that one could just pick a framework that uses all this. But I would feel much more comfortable with choosing among the growing list of frameworks if I had a clearer understanding of the basics. Thanks in advance. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240676 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
Hey Crow... Do we want to know how you found that site? =] -- Alan Rother Macromedia Certified Advanced ColdFusion MX 7 Developer ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240678 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
OOps. Sry. I shoulda flagged that (semi) NSFW. Seriously, though, you see worse on public billboards! :) Joe Rinehart wrote: Aw man, that's gonna get flagged in my corporate firewall logs for sure! -Joe On 5/16/06, Crow T. Robot [EMAIL PROTECTED] wrote: Heh - this has prolly been mentioned before, but the girl on this cover must be leading a double life http://tinyurl.com/89lue :) Andy Matthews wrote: Ooops... This book: http://www.oreilly.com/catalog/hfdesignpat/ ? !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: Ben Nadel [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 12:06 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. Ian, I did a trip into the land of OOP and one of the things that I really found useful was the book Headfirst Design Patterns. Its about design patterns, not specifically object oriented programming, but the two have a lot of overlap in programming. It's a very easy to read, well put together book. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240679 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
Head First Design Patterns is a good book, but some of the patterns in there may be overkill for the simple idea Ian is looking for. I posted some sample code that is not tied to a Framework (but could be used by any of them) that demonstrates the fairly common idea of a Person table and an Address table (one to many relationship). I used a Service Layer CFC to handle the interactions between the Data Access Objects and Beans. http://mattw.mxdj.com/sample_servicedaobean_files.htm There are also many good code examples that do use a framework from Sean Corfield, Brian Kotek, Kurt Wiersma, Matt Woodward, etc. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240680 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
One book I found really helpful was Just Java 2 (http://www.amazon.com/gp/product/0130105341/qid=1147801102/sr=2-3/ref=pd_bbs_b_2_3/103-1094486-3133417?s=booksv=glancen=283155) Readable, really discusses the concepts of OOP and I found it really easy to follow and understand. Java-centric, of course, but a good read. -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 12:46 PM To: CF-Talk Subject: SOT: OOD/Design Patterns and ColdFusion. I guess I just do not have a natural OOP/OOD/OOA type mind. I get a basic object and its purpose to encapsulate data and functionality. But as soon as I try to start putting objects together to build a system, I quickly get lost in a quagmire. This usually results in my falling back to my procedural experience, peppered with a small object or two, to get the current task done by my deadline. So can anybody point out a good resource or ten on how to actually program with object and patterns. Everything I have found to date seems to be geared on selling the why one should program this way and are very light on the how one actually writes the code. Conversely, if I can pick the minds of this group, maybe somebody can give me some pointers on how one would solve a common web requirement with objects/cfcs. This would be a basic admin task of showing a list of items allowing for the adding and editing of these items with data validation and the storage of the data in a database. I hear terms like beans, DAO's, MVC patterns ect. But I can't figure out how to even start coding all this. I suppose that one could just pick a framework that uses all this. But I would feel much more comfortable with choosing among the growing list of frameworks if I had a clearer understanding of the basics. Thanks in advance. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240681 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
Well, at the risk of getting yelled at for being so OT...I had seen this book and the other site posted on another forum a while back. :) I'll drop it at that, I shouldn't have brought it up in the first place... Alan Rother wrote: Hey Crow... Do we want to know how you found that site? =] ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240682 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Maybe you should be more concerned about that itching feeling instead of your corporate server logs? !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: Joe Rinehart [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 12:29 PM To: CF-Talk Subject: Re: OOD/Design Patterns and ColdFusion. Aw man, that's gonna get flagged in my corporate firewall logs for sure! -Joe On 5/16/06, Crow T. Robot [EMAIL PROTECTED] wrote: Heh - this has prolly been mentioned before, but the girl on this cover must be leading a double life http://tinyurl.com/89lue :) Andy Matthews wrote: Ooops... This book: http://www.oreilly.com/catalog/hfdesignpat/ ? !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: Ben Nadel [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 12:06 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. Ian, I did a trip into the land of OOP and one of the things that I really found useful was the book Headfirst Design Patterns. Its about design patterns, not specifically object oriented programming, but the two have a lot of overlap in programming. It's a very easy to read, well put together book. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240683 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Matt... Thanks for that link. That code is a wealth of information about encapsulating data. Appreciated. !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: Matt Williams [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 12:40 PM To: CF-Talk Subject: Re: OOD/Design Patterns and ColdFusion. Head First Design Patterns is a good book, but some of the patterns in there may be overkill for the simple idea Ian is looking for. I posted some sample code that is not tied to a Framework (but could be used by any of them) that demonstrates the fairly common idea of a Person table and an Address table (one to many relationship). I used a Service Layer CFC to handle the interactions between the Data Access Objects and Beans. http://mattw.mxdj.com/sample_servicedaobean_files.htm ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240684 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
You're welcome Andy. I was where you are about 3-4 months ago, just trying to get a grip on it all. I wrote that sample code a couple of weeks ago after seeing these same type of questions pop up here and on some other email lists. I'm working on a bit of a guide that shows you how I created those CFCs and what all is going on with them. Of course as I write it I think of more and more to explain. But hopefully soon I'll be able to post some of it. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240685 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
There is also a book java for coldfusion developers that you may find useful. I did buy it, but it is still sitting on my shelf :-) -Original Message- From: Matt Williams [mailto:[EMAIL PROTECTED] Sent: 16 May 2006 19:10 To: CF-Talk Subject: Re: OOD/Design Patterns and ColdFusion. You're welcome Andy. I was where you are about 3-4 months ago, just trying to get a grip on it all. I wrote that sample code a couple of weeks ago after seeing these same type of questions pop up here and on some other email lists. I'm working on a bit of a guide that shows you how I created those CFCs and what all is going on with them. Of course as I write it I think of more and more to explain. But hopefully soon I'll be able to post some of it. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240686 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
My suggestion would be to learn some basics of another language that is written to take advantage of OOP. As you know, ColdFusion isn't, and there aren't good books that show you how to think that way via code in ColdFusion. I've done that. I've gone through a couple of courses and tutorials on beginning Java. I get how to create an object with data and methods, I can inherit and encapsulate. Where I loose it, is trying to take a programming requirement. See the objects and/or patterns. And write a group of objects to work together to solve the real world application. I can't make the jump from a Java sample project of a group of jam objects to creating an application to manage trima machine data for our blood bank. -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - C code. C code run. Run code run. Please! - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240687 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Where I loose it, is trying to take a programming requirement. See the objects and/or patterns. And write a group of objects to work together to solve the real world application. I can't make the jump from a Java sample project of a group of jam objects to creating an application to manage trima machine data for our blood bank. This process is somewhat similar to modeling data requirements for a relational database, actually. Just as you need to identify the entities and relationships within your database, you need to model the objects and their relationships within an OO design. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240688 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Ah so you're more having problems with establishing relationships between the objects rather than understanding OOP in general. I had similar problems years ago when I got into OO concepts. Believe it or not, what got me over the hump was a simple program I was working that dealt with cars. I was able to, in my mind, visualize a car and its components. It was only then that I had that click moment. Then perhaps those other books would be of use for you after all. Steve The Boss Brownlee http://www.orbwave.com/cfjboss -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 2:28 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. My suggestion would be to learn some basics of another language that is written to take advantage of OOP. As you know, ColdFusion isn't, and there aren't good books that show you how to think that way via code in ColdFusion. I've done that. I've gone through a couple of courses and tutorials on beginning Java. I get how to create an object with data and methods, I can inherit and encapsulate. Where I loose it, is trying to take a programming requirement. See the objects and/or patterns. And write a group of objects to work together to solve the real world application. I can't make the jump from a Java sample project of a group of jam objects to creating an application to manage trima machine data for our blood bank. -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240689 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: OOD/Design Patterns and ColdFusion.
I found the following books very helpful when I started trying to tackle this vast subject: Object Technology: A Manager's Guide: http://www.amazon.com/gp/product/0201309947 (don't worry about the title, it is useful by anyone, not just managers) Object-Oriented Thought Process: http://www.amazon.com/gp/product/0672326116 regards, Brian On 5/16/06, Steve Brownlee [EMAIL PROTECTED] wrote: Ah so you're more having problems with establishing relationships between the objects rather than understanding OOP in general. I had similar problems years ago when I got into OO concepts. Believe it or not, what got me over the hump was a simple program I was working that dealt with cars. I was able to, in my mind, visualize a car and its components. It was only then that I had that click moment. Then perhaps those other books would be of use for you after all. Steve The Boss Brownlee http://www.orbwave.com/cfjboss -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 2:28 PM To: CF-Talk Subject: RE: OOD/Design Patterns and ColdFusion. My suggestion would be to learn some basics of another language that is written to take advantage of OOP. As you know, ColdFusion isn't, and there aren't good books that show you how to think that way via code in ColdFusion. I've done that. I've gone through a couple of courses and tutorials on beginning Java. I get how to create an object with data and methods, I can inherit and encapsulate. Where I loose it, is trying to take a programming requirement. See the objects and/or patterns. And write a group of objects to work together to solve the real world application. I can't make the jump from a Java sample project of a group of jam objects to creating an application to manage trima machine data for our blood bank. -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240691 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Thanks Matt. You blog looks interesting. I'm downloading the sample code now. I look forward to your description of the thought process to create these files. I suspect that is exactly what I am looking for. A straight forward example of here is a problem, here is how I broke it down into an object oriented design and here is the code to make it do this. Thanks again. -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - C code. C code run. Run code run. Please! - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240692 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Just as you need to identify the entities and relationships within your database, you need to model the objects and their relationships within an OO design. But this is where I get so confused. It is hard for me, being a mostly self-taught procedural programmer. I'm trying to teach myself OOP programming, but I have no place to go when I get stuck. I have nobody to go to with a how would you solve this problem? And I don't get enough of the concepts to hammer it out myself. -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - C code. C code run. Run code run. Please! - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240700 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Ah so you're more having problems with establishing relationships between the objects rather than understanding OOP in general. Exactly, except I have not managed to make much progress toward an aha moment. My current task: Create an interface to enter and administer Trima machine data. The data for a trima machine is very simple: ID, Serial Number, Version, In-Service and Out-of-Service dates as well as a history of locations. The history of locations is collection of dates showing when and where an individual machine was/is located. We have our database tables; one for the basic Trima data and a sub-table for the location history. Procedurally, I could do this in my sleep. Create a master page listing all the current Trima machines with links to a detail form page for editing and/or adding a new machine. This form would call an action page that would validate the submitted data. Then if valid, write the data to the database otherwise return to the form with some kind of error feedback. But I can not convert this to an object orientated design. I can create a simple object that would represent a trima machine which I believe is often called a bean. I think I understand how one would separate the database logic into a DAO. But I don't know how one relates these two objects. I start really getting lost trying to figure out where validation goes and how it is used. Is it part of the bean, the DAO, or some other piece? Is it good or bad to put bad and/or partial data into the bean because some of the form data was good and some was bad? How does one use a form first to show the current bean data and then to show the form submitted data with error feedback? And how does one create the master list of all current trima machine beans? I feel like I'm standing the top of a high procedural mountain peak. Looking down into an inviting lake of OOP goodness. But I can not, for the life of me, find a path down the slope of the mountain and through the forest to the lake. I keep getting lost and having to trek back to the top of the mountain. Sorry for the sudden attack of the metaphors â long meetings today. -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - C code. C code run. Run code run. Please! - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240702 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: OOD/Design Patterns and ColdFusion.
Ian, I think this project is a perfect place to start since you're only dealing with one object and its data. I'll provide my thoughts and hopefully it will help. One thing I want to say is that you're still performing the steps procedurally, but the data is manipulated as attributes of an object. You are still going to create a form and then submit to a processing page that validates everything. How you build the application remains unchanged. But I can not convert this to an object orientated design. I can create a simple object that would represent a trima machine which I believe is often called a bean You're on the right track here. You create the Trima Bean. It simply holds the attributes and get/set methods for each attribute of a trima machine. Since the bean's function is to accept and give the data while it's being manipulated, the validation should be done at this point. I think I understand how one would separate the database logic into a DAO. Correct, the TrimaDAO handles *all* access to the datasource. This is its only purpose, which is why the data should not be validated here. It has the CRUD methods [create/read/update/delete]. Each of these methods has one argument which accepts a Trima Bean which is a struct. cfargument name=TrimaBean type=struct required=true So a sample call would be: trimaDAO = createobject(component, com.bloodsource.trimaDAO); trimaDAO.update(trimaBean); Is it good or bad to put bad and/or partial data into the bean because some of the form data was good and some was bad? IMHO, since validation is done by the bean, partial data in one of the attributes is not acceptable. How does one use a form first to show the current bean data and then to show the form submitted data with error feedback? FORM PAGE -- cfscript trimaBean = createobject(component, com.bloodsource.trimaBean); trimaDAO = createobject(component, com.bloodsource.trimaDAO); trimaBean.setMachineID(64); currentTrimaBean = trimaDAO.read(trimaBean); /cfscript form action=ProcessTrimaBean.cfm input type=text name=PlateletLevel value=#currentTrimaBean.getPlateletLevel()# input type=text name=BloodType value=#currentTrimaBean.getBloodType()# etc... /form PROCESSING PAGE -- cftry cfscript trimaBean = createobject(component, com.bloodsource.trimaBean); trimaDAO = createobject(component, com.bloodsource.trimaDAO); trimaBean.setPlateletLevel(form.PlateletLevel); trimaBean.setBloodType(form.BloodType); etc... trimaDAO.update(trimaBean); /cfscript cfcatch cfset alertMessage = trimaBean.invalidDataMessage -- DISPLAY ERROR INFORMATION HERE -- /cfcatch cftry ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240728 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54