[Bluej-discuss] Objects example

Yonel Scutaru yonel at istar.ca
Sun Apr 23 20:54:30 BST 2006


Hi Chris,

First we have to understand that objects have proprieties (variables) 
and know how to do things (methods).
In your case the basic object might be a room. A room is a room is a 
room. No matter if it is part of an apartment, office or restaurant.
It has dimensions, windows (0 windows is an option too), doors.
It knows how to calculate the heating  needs, the cleaning  needs or the 
cleaning methods, it can  draw itself, increase its dimensions thus 
communicating with the other rooms, etc.

What I am trying to say is that your project does not define what the 
building, and its rooms have to do.
Once these actions are defined we can group the objects from the most 
general : the room to the more specific: bedroom, office room, bathroom, 
etc each one inheriting from the general room the proprieties and the 
methods and adding or modifying them for the specific role.
Hope it was not too complicated. If you are interested I can give an 
example of more object oriented application.

Yonel

chris huston wrote:

> Hello,
> I hope I can post this message here.
> I have a question that I hope can be answered. I have a been programming
> in Cold Fusion and PHP for many years, using includes and components.
>
> I've always wanted to  learn the Object method of programming but up 
> till this time [10 years +], I haven't found a decent resource that 
> lets me visualize the methodology. Blue Jay almost gets me there.
>
> My experience has been that if you need to call a "chunk of code" create a
> self contained function that you can use [in a central function file],
> instead of rewriting it over and over again. This has been that 
> closest I've gotten to "Pseudo" object coding practices.
> I still can't see how object coding clearly.
> If someone could help me with this example using the "blue jay way" of 
> thinking. I would be extremely thankful.
>
> Example----
> project: Building
>
> class:residential
> method:
> createApt(int windowQty, int roomBedRoomQty, int bathroomQty, int patio)
> method:
> createStudio(int windowQty, int bathroomQty)
>
> class:commercial
> method:
> createOffice(int windowQty, int seatingQty)
> method:
> createRestaurant(int bathroomQty, int seatingQty, boolean bar)
>
> class:utility
> method:
> createStorage(boolean sink, boolean lockers)
> method:
> createCarpark(int level, string sqrFootage)
>
> My first option would be create a class for each type of space that 
> may appear in the building [above]. My second option would be to 
> create a class called space, initially ask for the space type 
> [residential, commercial, etc.] then call another class with case 
> statements that would roll through each parameter. Which method would 
> be most future - expandable, and Correct [object wise].
>
> Does this "high-level" building code look correct... would there be 
> another way to display a building in the object metaphor?
>
> Thank you for your time..
> chris
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>mailing list bluej-discuss at bluej.org
>To unsubscribe or change your preferences, go to
>http://lists.bluej.org/mailman/listinfo/bluej-discuss
>  
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bluej.org/pipermail/bluej-discuss/attachments/20060423/0a0a9cf1/attachment.html


More information about the bluej-discuss mailing list