User Profile
Collapse
-
I agree with you Dormi. Here.... I found an excerpt of why these are *supposedly* so bad:... -
Hey Dan, thanks for this great comparison. Let me ask you a few questions about the methods you chose plus I'd like to respond to a few of your comments.
Yes, agreed... I see it now only because it happened to me where a small change created this huge ripple effect throughout my program. A lesson well learned. The good thing is that I never seem to get tired of refactoring my code. :) I'll now go back and redo these classes the right...Leave a comment:
-
And, BTW: what's all the fuss about using getters and setters? I have read a lot of things about how a "true" OO system really isn't OO if you use setters and getters. I'm sure you guys know what they are talking about but its a bit over my head. Can someone please explain?
If needed, I will grab some of these links.Leave a comment:
-
Hey!! I never got notification that this post was updated since I last posted here!!! :(
Well, I'm glad to see that this thread is still going. I came back today to tell you guys that I now see the point about designing classes where it won't affect your application code. Here's what happened to me this past weekend....
I needed to add some functionality to my app and when I went into the class to make the change,...Leave a comment:
-
Atli, I forgot to ask in my last post but in your upload class, I see that you have multiple getters and setters but that only 2 of them are actually being called. Am I reading this right? If I am, I am wondering why you have them in there?
For example.. You have the following that are not being used, or called:
getUploadDir()
getMaxFileSize( )
getAllowedExten sions()
Was this intentional?Leave a comment:
-
Heya Atli,
I totally understand where you are coming from with your example. For some reason... My mind wants to gravitate toward making a class for each function to be performed. In your example, instead of making a music playback class, I would have wanted to make a play class, a pause class, a stop class, etc. To me, it just seems cleaner to do it like that. In fact, I went back through a program I made where I had originally designed...Leave a comment:
-
Atli, I have been looking over your upload class and I am curious as to why you allow the moveFile method to be accessible from the outside? I'm not disagreeing with you but only looking to understand your logic.
To me, the moveFile method should probably be made part of the internal class itself away from the outside, because the whole job of a file upload class is to move and upload a file anyway, right?
Why would...Leave a comment:
-
Thanks for the replies guys. I think I will re-read this entire post and see if I can rework this example class trying to correct the mistakes and repost it. Thanks for helping me out on this. :)Leave a comment:
-
Hold on.... I think I understand what you are saying here Atli.. So you mean.. it isn't good to tie all of my "functional ity" to the constructor because I limit the class. Yes? Here's what I think I am understanding.. By not tying al of my functionality to the constructor and by using getters and setters, I just use those for any current functionality I have or need and then if I require more functionality, I just add more getters and setters....Leave a comment:
-
Ok, I spent the night writing a simple upload script that pretty much demonstrates what I am talking about. My first example sucked but the following is a class that can actually be used. The main goal of the class is to take a file from a user, clean the filename and upload it to the server. There are also options that the user can toggle in an array that's passed to the constructor.
When I designed this class, I didn't see any other...Leave a comment:
-
Thanks for the advice Markus. I'll do that. I seem to do better with books anyhow.Leave a comment:
-
Hi Acoder. Yes, exactly.
If you look, you will see an alert() in the success part of the lower function. What I really want to do is replace that alert with a nice dynamic css styled div to tell the user that their data was successfully received. That's really all I'm doing. :)
I just don't know how to tie these functions together. Both the upper and lower functions use different datatypes. One uses json and the other...Leave a comment:
-
How to use / combine 2 jquery scripts that use two different datatypes
I have one jquery function that submits data via a datastring to my server. This works great. On success, I currently have a little alert box that lets the user know that the data was stored.
I now have a second function that gets back a json response for a success or failure from the server and will echo to the user whether the data was saved successfully or not. This function should replace the alert box in the bottom most function.... -
There is some really great information here. Thanks for all the help guys. I am going to digest this and respond this weekend when I have a little more free time. I've already read this over once and will re-read it again this weekend before I respond. I'm not going to let this thread die!! :)Leave a comment:
-
Atli,
I have been doing a bit more reading on this and have looked over the link on interface. Not certain exactly how that would help me out just yet but of course it's because I don't fully inderstand it yet. I will re-read it and look for some additional info on that.
Regarding post #5, in your example... Your private method acts as a mutator and the public getHello acts as an accessor, right?
Could...Leave a comment:
-
Heya Atli. I'm glad that you joined in to help. :)
OK. I understand this acutally. I was just thinking that maybe it would be better to make methods private where possible for added security but I see that isn't always a good thing or even realistic especially after seeing your example.
OK, I understand that. I guess my question is what if a public method really has nothing to do with any of the other...Leave a comment:
-
Is this not acceptable?
I am under the impression that each class should have a single function (and not in the literal sense). Let me give you an example. I have a class with two methods. The first method gets data from a database then internally passes the values to the second method where the data is checked then returned to the main script. In the constructor, I call the first method which starts the process. My thoughts...Leave a comment:
-
Ok, I understand that. Thanks. :)
In your example where you said that you would shorten it to sayHello(), isn't this acting more like a simple function than a class? This was the way that I was using it before. Because I had so many of these types of methods in a single class and would call them directly, I couldn't keep the methods private.
I know that in your example you are using the constructor to call the sayHello...Leave a comment:
-
OOP clarification
Hey everyone. I'm back in search of a better understanding of OOP. I feel like these past couple of months have paid off for me because I am at a point where I am really beginning to understand how this all works. I'd like to get some clarification on a few things first.
My questions stem from wanting to use private members and methods. I know that there is a reason for making methods and members public and private and honestly I'm... -
Hi Ciary,
You're right, array_splice is not right. It is doing exactly what it should do but it's not right for what I need.
Let me try and explain again. Please look at the sample data below. In the example data below, there is only one actual report with 4 people associated. The 4 people associated with the report are what are causing all 4 rows to echo.
Each report has its own report number as the primary...Leave a comment:
No activity results to display
Show More
Leave a comment: