LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Traffic Signal OOP

I'm trying to do the Traffic Signal CLD practice program using OOP techniques.  As you can tell by my question, I'm new to OOP programming.  In my attachment, I've constructed a class for the individual traffic lights in a signal  head.  Intuitively, it seems that the next step would be to create a class for the traffic signal assembly (signal head) which contains at least 3 of the traffic light objects.  But if I do this, I won't be adding any new information.  Should I just be satisfied with what I've got so far and instantiate a traffic lite for each of the 4 traffic signal heads? 

 

Thanks in advance.

0 Kudos
Message 1 of 5
(3,889 Views)
Personally I would think that creating a class for the individual lights would be over-decomposition. The individual lights can be either on or off, and that is always done in coordination with the other lights in the head.

You could then have an "intersection" objects that would have multiple child "light head" objects -- along with properties that would at a high level describe how the intersection is to operate.

However there is a bigger problem here. All this conceptual work takes time -- which for a certification exam is something that you don't have a lot of. You might be able to get away with it for the CLA exam because for that test you aren't expected to create a functional program. The CLD output however is expected to work at the end of the test, so don't get fancy.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 5
(3,876 Views)

Thanks for your advice.  Not planning to take the exam.  Just trying to learn OOP.

0 Kudos
Message 3 of 5
(3,845 Views)

The biggest issue I have had with OOP is people trying to make it a lot more complicated than it needs to be.  I am with Mike: each individual LED does not make sense as an object (you are not gaining anything at all).  But the collection of LEDs that work together does make sense as an object.  Then you have 4 of those object for an intersection (which does make sense as an object).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 5
(3,843 Views)
Ahhhh, well in that case check out this...

http://www.notatamelion.com/2015/04/06/objectifying-labview/

...and next couple post following on. In addition, you will also find on the website a couple presentations I made at NI Weeks on OOP.

Mike...

PS: In your modelling remember that not all intersections are 4-way... and intersections can have modes of operation.

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 5
(3,839 Views)