I would try to extract all those things that are 100% the same, generalize the code, then make a higher level abstract object that the others extend from. I have tried this technique before when I run into the problems you are describing and it has worked out in the past.
<br><br><div><span class="gmail_quote">On 11/28/05, <b class="gmail_sendername">Scott Phillips</b> <<a href="mailto:scott.phillips@drake.edu">scott.phillips@drake.edu</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Here's the problem I've been having with my OO approach. If someone has any<br>words of wisdom here, that'd be great.<br><br>Every time I need to work with a new "thing" (object) I find myself<br>creating a new class that is almost identical to all the others I've
<br>written. In fact, when pressed for time, I've been known to save a copy of<br>an existing class, do a find/replace on a number of terms, and then make<br>whatever changes are necessary. So I've got a dozen or more 200-300 line
<br>classes that are 80% identical (and that's with stuff like db connectivity<br>abstracted out). They all seem to do the same things... get some data,<br>manipulate it, store it, retrieve it. Yeah, I know that this should raise
<br>some big red flags in terms of my approach but I keep doing it anyway.<br><br><br><br><br>At 04:49 PM 11/25/2005 -0600, you wrote:<br>>I agree. There's not a whole lot of difference so far, but I think that's<br>>because I haven't learned enough to do much else with classes than put a
<br>>bunch of functions inside them. I really haven't begun to scratch the<br>>surface yet. I'm inheriting my data connections from a class file, which<br>>seems like an easier to do it. I'm not sure I couldn't have done the same
<br>>thing with a bunch of functions in an included file. I guess the main<br>>benefit I'm seeing is that I'm putting a lot more code into functions and<br>>putting them in a separate file. I'm not sure it's OOP that is making me do
<br>>that, but I wasn't doing it before and I'm really starting to see the<br>>benefit because it makes things a lot easier to figure out when I come back<br>>and look at the code several months later. I'm giving OOP the credit for
<br>>that, although I may be off base.<br>><br>>Carl<br>><br>>-----Original Message-----<br>>From: <a href="mailto:ciapug-bounces@cialug.org">ciapug-bounces@cialug.org</a> [mailto:<a href="mailto:ciapug-bounces@cialug.org">
ciapug-bounces@cialug.org</a>] On Behalf<br>>Of Dave J. Hala Jr.<br>>Sent: Friday, November 25, 2005 11:10 AM<br>>To: <a href="mailto:carl-olsen@mchsi.com">carl-olsen@mchsi.com</a>; PHP List<br>>Subject: RE: [ciapug] Web Professionalism
<br>><br>>I have all kinds of inc files with string formating libraries, database<br>>connectivity, listboxes and all that stuff... I have tons of code that I<br>>reuse, that code is kept in include files. I have my html include,
<br>>database connectivity include, formatting include, etc.<br>><br>>They are just not called "objects" and "classes", they are collections<br>>of functions and procedures.<br>><br>>I have almost no php code in any of my .html files, in fact I keep all
<br>>my html and php code seperate.<br>><br>><br>>On Fri, 2005-11-25 at 09:45, Carl Olsen wrote:<br>> > I appreciate it. I think you verbalized it well. You are still learning<br>> > and your code just reflects the level you are at. That's exactly what I'm
<br>> > doing. The difference I see is that I frequently do the same things over<br>> > and over again. I'm frequently writing code to maintain some kind of<br>> > inventory table in a database. I've written class files that contain all
<br>> > the code I need for display a drop down list (you feed it the name you<br>>want<br>> > the input control to have, the value if it has a value, and all the html<br>> > necessary to rending the control. I've written class files with nothing
<br>>but<br>> > string formatting functions. I usually write a class that opens and<br>>closes<br>> > my connection to the database and then my other classes that maintain the<br>> > tables inherit from that database class. The more I do it, the more I
<br>>like<br>> > it. It makes the code modular and reusable. I'm finding it easier to go<br>> > back and maintain it later. I'm moving from a procedural model to an<br>>object<br>> > oriented model, because I've been doing the procedural model for so long
<br>> > it's no longer difficult. When I first started learning PHP, it was<br>>easier<br>> > to drop all the code directly into the HTML page in the exact spot where<br>>it<br>> > was going to perform some function. Now that I feel comfortable with
<br>>that,<br>> > I'm looking for ways to make the code more modular, and OOP is it.<br>> ><br>> > Thank you very much!<br>> ><br>> > Carl<br>> > <a href="http://www.carl-olsen.com/">
http://www.carl-olsen.com/</a><br>> ><br>> ><br>> > -----Original Message-----<br>> > From: <a href="mailto:ciapug-bounces@cialug.org">ciapug-bounces@cialug.org</a> [mailto:<a href="mailto:ciapug-bounces@cialug.org">
ciapug-bounces@cialug.org</a>] On<br>>Behalf<br>> > Of Dave J. Hala Jr.<br>> > Sent: Friday, November 25, 2005 7:58 AM<br>> > To: <a href="mailto:carl-olsen@mchsi.com">carl-olsen@mchsi.com</a>; PHP List
<br>> > Subject: RE: [ciapug] Web Professionalism<br>> ><br>> > It's difficult to verbalize. Let me try... I think that procedural<br>> > programming is more like the thought process I use. Not that I don't
<br>> > sometimes think in "object mode", because I usually do at the beginning<br>> > of the process. (that's the curse of us south paws...)<br>> ><br>> > Usually, I'll conceptualize the problem, then break it into components
<br>> > (objects) Typically, I'll start in the middle of the problem and work<br>> > my way out. Once I have compartmentalized all my components, (objects)<br>> > I'll define each one using psuedo code. Then I'll convert that to code.
<br>> ><br>> > The pseudo code tends to be really linear and that seems to favor<br>> > procedural methods. If I had "pre-made" objects, I could probably skip<br>> > the definition stage. Then I would be doing OOP. However, most of my
<br>> > stuff is very, very specific and won't fit well into a generic object<br>> > container. ( did I say that?!!)<br>> ><br>> > Not to be off subject, but I think the key component of the "web
<br>> > proffesional" topic isn't really about how everyone else is doing it, or<br>> > what the current trends are, but its more about continually learning and<br>> > applying new techniques as they are appropriate in your envirnoment. In
<br>> > other words, developers need to continually grow and evolve, as do the<br>> > systems they maintain.<br>> ><br>> ><br>> > On Thu, 2005-11-24 at 19:45, Carl Olsen wrote:<br>> > > What do you like better about procedural?
<br>> > ><br>> > > -----Original Message-----<br>> > > From: <a href="mailto:ciapug-bounces@cialug.org">ciapug-bounces@cialug.org</a> [mailto:<a href="mailto:ciapug-bounces@cialug.org">ciapug-bounces@cialug.org
</a>] On<br>> > Behalf<br>> > > Of Dave J. Hala Jr.<br>> > > Sent: Thursday, November 24, 2005 6:04 PM<br>> > > To: <a href="mailto:carl-olsen@mchsi.com">carl-olsen@mchsi.com</a>; PHP List
<br>> > > Subject: RE: [ciapug] Web Professionalism<br>> > ><br>> > > I'm not against OOP PHP code, I do a little of it but I still prefer to<br>> > > do procedural.<br>> > ><br>
> > > On Thu, 2005-11-24 at 16:27, Carl Olsen wrote:<br>> > > > I have a question for everyone. How many people prefer to write<br>> > > procedural<br>> > > > PHP code as opposed to object oriented (OOP) PHP code?
<br>> > > ><br>> > > > Carl<br>> > > > <a href="http://www.carl-olsen.com/">http://www.carl-olsen.com/</a><br>> > > ><br>> > > > -----Original Message-----<br>> > > > From:
<a href="mailto:ciapug-bounces@cialug.org">ciapug-bounces@cialug.org</a> [mailto:<a href="mailto:ciapug-bounces@cialug.org">ciapug-bounces@cialug.org</a>] On<br>> > > Behalf<br>> > > > Of laith<br>> > > > Sent: Thursday, November 17, 2005 6:43 AM
<br>> > > > To: <a href="mailto:ciapug@cialug.org">ciapug@cialug.org</a><br>> > > > Subject: Re: [ciapug] Web Professionalism<br>> > > ><br>> > > > Keeping up is always good.
<br>> > > ><br>> > > > Unfortunately not everyone thinks this way so many good things you<br>>might<br>> ><br>> > > > learn will not be useful for longer than it should take.<br>
> > > ><br>> > > > Laith<br>> > > ><br>> > > > Chris Van Cleve wrote:<br>> > > > > There has been a flurry of articles this week about New Web<br>> > > > > professionalism.
<br>> > > > ><br>> > > > > See: <a href="http://webstandards.org/buzz/archive/2005_11.html#a000590">http://webstandards.org/buzz/archive/2005_11.html#a000590</a><br>> > > > > <a href="http://webstandards.org/">
http://webstandards.org/</a><br>> > > > > <a href="http://www.456bereastreet.com/archive/200511/">http://www.456bereastreet.com/archive/200511/</a><br>> > > > > a_web_professional_can_never_stop_learning/
<br>> > > > ><br>> > > > > I believe in this whole-heartedly. Keeping up with standards,<br>> > > > > methodologies, trends, etc. is important as a true professional. I<br>>am
<br>> ><br>> > > > > curious what everyone else's take on this is.<br>> > > > ><br>> > > > > Chris VC<br>> > > > ><br>> > > > > _______________________________________________
<br>> > > > > ciapug mailing list<br>> > > > > <a href="mailto:ciapug@cialug.org">ciapug@cialug.org</a><br>> > > > > <a href="http://cialug.org/mailman/listinfo/ciapug">http://cialug.org/mailman/listinfo/ciapug
</a><br>> > > ><br>> > > > _______________________________________________<br>> > > > ciapug mailing list<br>> > > > <a href="mailto:ciapug@cialug.org">ciapug@cialug.org</a>
<br>> > > > <a href="http://cialug.org/mailman/listinfo/ciapug">http://cialug.org/mailman/listinfo/ciapug</a><br>> > > ><br>> > > > _______________________________________________<br>> > > > ciapug mailing list
<br>> > > > <a href="mailto:ciapug@cialug.org">ciapug@cialug.org</a><br>> > > > <a href="http://cialug.org/mailman/listinfo/ciapug">http://cialug.org/mailman/listinfo/ciapug</a><br>>--<br>><br>
>Open Source Information Systems, Inc. (OSIS)<br>>Dave J. Hala Jr., President <<a href="mailto:dave@osis.us">dave@osis.us</a>><br>>641.485.1606<br>><br>>_______________________________________________
<br>>ciapug mailing list<br>><a href="mailto:ciapug@cialug.org">ciapug@cialug.org</a><br>><a href="http://cialug.org/mailman/listinfo/ciapug">http://cialug.org/mailman/listinfo/ciapug</a><br>><br>>_______________________________________________
<br>>ciapug mailing list<br>><a href="mailto:ciapug@cialug.org">ciapug@cialug.org</a><br>><a href="http://cialug.org/mailman/listinfo/ciapug">http://cialug.org/mailman/listinfo/ciapug</a><br><br>_______________________________________________
<br>ciapug mailing list<br><a href="mailto:ciapug@cialug.org">ciapug@cialug.org</a><br><a href="http://cialug.org/mailman/listinfo/ciapug">http://cialug.org/mailman/listinfo/ciapug</a><br></blockquote></div><br>