As I have stated before, programming is not a part of my daily basis work. I read some codes, discuss implementation strategies and help modeling the architecture, but at the end of the day, I’m using Word and/or Excel, not some fancy IDE people use nowadays 😁.
With that said, there’s a thing that I see a lot that, I think, may go against the concept of Object. According to Wikipedia, an Object is an instance of a class. Also according to Wikipedia, a class is a definition of data format and procedures for a given object. Helpful (not so much). In other words, a class defines a car and an object is a DeLorean DMC-12👌.
This is a really simple and not even close to a real-life incident class. I can create a new incident, which basically means it will be stored in a database, I can update some information, I can delete if needed and I can close the incident (case I solve the problem, for example).
(I put the close method in there so it would not be an almost CRUD example 😁.)
You may have noticed that I did not write a Read (or find, or get, or return) method to retrieve any info about the incident. And the reason for it is that I’m not quite sure if that is something the Object should be aware of. I mean, you can create the incident number 123 about a broken keyboard that must be fixed in one hour. You can also update that info so the keyboard can be fixed in two days, instead. You can close it in case you give a new keyboard to your client or you can delete it in case you don’t work fixing keyboards. But, I think, you cannot search for the incident 123 because it already is incident 123.
“Oh, but you can instantiate this class not providing any information and then fetch the data”
Yes, you can! But an instance with no data is considered an object? What is an incident numbered null about null? If this isn’t anything, how can it know how to find it’s data?
“Well, you can instantiate it with its number so you can fetch the remaining of the information”
Also true. But isn’t it strange to write new Incident(123)? Yes and no, I think. Yes, because only this doesn’t mean anything and because you’re saying it’s a new incident. And no because new here refers to something that did not exist at that time of the program flow, so it can be something entirely new but also a new object that exists.
I’m starting to ramble here so I’ll get to the point that get me thinking about it in the first place (and I consider myself to be an object person 😐). So far I have been talking about a single object, and the incident number 123 could be able to read its own information. But should incident 123 be able to return all other incidents? Or all incidents about monitors? Should incident null do it?
What I’m thinking is that these methods that return data could be static methods that returns an object of that given class.
This is something that makes sense to me. I have not made any intense research about the topic, but searching on Google I didn’t find anything related to this, maybe it’s the terms I’m using, don’t know. For now, I just really wanted to get this out of my system 😁. Maybe I’ll try this on one of my so-called projects.