473,480 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Classes as concepts.

I had read that you should use classes to represent concepts. How does
this work and what kind of concepts should be reresented as classes.

Jul 23 '05 #1
6 1378
enki wrote:
I had read that you should use classes to represent concepts. How does
this work and what kind of concepts should be reresented as classes.


I think you're in a wrong newsgroup. Please try 'comp.object' or a good
OOD (Object-Oriented Design) book.

V
Jul 23 '05 #2
enki wrote:
I had read that you should use classes to represent concepts. How does
this work and what kind of concepts should be reresented as classes.


That verbiage is a cheap way to inspire you to think in terms of objects. It
can mislead.

Some folks say "read your requirements, and pull out the important-sounding
nouns". So even hallow this "search for nouns" as a phase in designing.

So suppose I find the noun "Car". That sounds like a harmless, obvious
candidate for a class, right?

It depends on the application. I could be writing a simulator for a
wind-tunnel to find a good shape for a car. I could be writing the
controller for a car's engine. I could be writing the point-of-sale software
for a carwash.

In each case, the Car itself is nebulous. Wind-tunnel software needs to
model shapes whose actual car-ness is irrelevant. The car's engine's
controller has only one car object, so its attributes can safely disperse
thru the controller. Nobody should ever decouple the controller from the
engine and plug it into a different car with different attributes. And
carwash software needs to track a carwash _event_, from buying a ticket to
entering the carwash with the ticket.

Ultimately, we need objects that present clean useful interfaces, so their
client modules can use them in straightforward ways. So suppose a carwash
user buys a ticket at a gas pump, then types their ticket number into the
carwash user interface, requesting permission to drive in. That leads to
this:

usersNumber = getUserNumberFromUI()
ticket = database.getTicket(usersNumber)

if ( ticket and
ticket.day == today and
not ticket.isWashedYet() and
ticket.isCreditChecked() ) then
UIdisplay("PLEASE ENTER CARWASH")
ticket.isWashedYet(true)
return true
else
UIdisplay("WRONG NUMBER. TRY AGAIN")
return false
end

This "analysis" has not revealed a Car object yet, despite the fact that
cars are a critical component of every carwash, anywhere. It reveals the
Ticket is the determinant object, and its behavior changes with its state.
After a wash event, you can't drive around and use your ticket again.

Objects are bags of behavior. Partitioning that behavior among objects helps
us invent objects that are easy to use right and hard to use wrong. The
search for nouns will help, but ultimately behaviors drive design. After
putting related behaviors together into an object, _then_ you think of a
name for that object's concept.

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand
Jul 23 '05 #3
On 8 Jul 2005 12:45:20 -0700 in comp.lang.c++, "enki"
<en*****@yahoo.com> wrote,
I had read that you should use classes to represent concepts. How does
this work and what kind of concepts should be reresented as classes.


Read the 1972 paper by David Parnas "On the criteria to be used in
decomposing systems into modules".
PDF at http://doi.acm.org/10.1145/361598.361623

Everywhere that Parnas writes "module", you substitute "class".

Jul 23 '05 #4
Victor Bazarov wrote:
enki wrote:
I had read that you should use classes to represent concepts. How does
this work and what kind of concepts should be reresented as classes.


I think you're in a wrong newsgroup. Please try 'comp.object' or a good
OOD (Object-Oriented Design) book.


Maybe it's you who is in the wrong newsgroup. Concepts play an
important role in STL:
http://www.sgi.com/tech/stl/stl_introduction.html

Jul 23 '05 #5
"Phlip" <ph*******@yahoo.com> wrote in message
news:4b****************@newssvr31.news.prodigy.com ...
This "analysis" has not revealed a Car object yet, despite the fact that
cars are a critical component of every carwash, anywhere. It reveals the
Ticket is the determinant object, and its behavior changes with its state.
After a wash event, you can't drive around and use your ticket again.


Further analysis ....

Use Case 100: Oh $%&%^&* it scratched the car!!

What should we do?

Carwash SME: Well we'd need to record the car details as part of our
diagnosis of the fault.

May need a new Value Object ..... we could call it Car ... we could call it
Vehicle ... we could call it ObjectInTheCarWash ... I'd probably start with
Car

:-)

Shane

--
" We should turn our attention back to pleasing our customer. That's what
keeps the paychecks rolling in." -- Ron Jeffries

Jul 23 '05 #6
Shane Mingins wrote:
Use Case 100: Oh $%&%^&* it scratched the car!!

What should we do?

Carwash SME: Well we'd need to record the car details as part of our
diagnosis of the fault.

May need a new Value Object ..... we could call it Car ... we could call it Vehicle ... we could call it ObjectInTheCarWash ... I'd probably start with Car


class Scratch {
string make;
string model;
string year;
string vin;
string location;
}

Okay. Now push that into a database and normalize it, and you have a Car
table. Maybe...

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand
Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2260
by: Bora | last post by:
I usually find that a number of unrelated classes require the same kind of operations. However, I don't want to duplicate code in multiple places. In Java, I've seen those "Utility Classes",...
24
2518
by: Alf P. Steinbach | last post by:
The eighth chapter (chapter 2.1) of my attempted Correct C++ tutorial is now available, although for now only in Word format -- comments welcome! Use the free & system-independent Open Office...
2
3009
by: Indiana Epilepsy and Child Neurology | last post by:
Before asking this questions I've spent literally _years_ reading (Meyer, Stroustrup, Holub), googling, asking more general design questions, and just plain thinking about it. I am truly unable to...
132
4712
by: Kevin Spencer | last post by:
About 2 years ago, and as recently as perhaps 1 year ago, I can recall seeing many posts about what language to use with ASP.Net. The consensus was that employers paid more for C# programmers, and...
4
2102
by: Chris F Clark | last post by:
Please excuse the length of this post, I am unfortunately long-winded, and don't know how to make my postings more brief. I have a C++ class library (and application generator, called Yacc++(r)...
31
1706
by: attique63 | last post by:
how could I write a program that will declare a class point. The class point has two private data members x and y of type float. The class point has a parameterized constructor to initialize both...
18
1858
by: Tom Cole | last post by:
I'm working on a small Ajax request library to simplify some tasks that I will be taking on shortly. For the most part everything works fine, however I seem to have some issues when running two...
1
1277
by: darrel | last post by:
Can anyone recommend a course/class/training event that focuses on OOP concepts in the context of ASP.net? My background: My education is in art/graphic design. Later spending most of my time...
1
2108
by: Swathika | last post by:
Hi, Sometimes, you never get chance to learn 'Advanced Design Concepts and Real-time Scenarios' from institutes or through book-learning. But, in my blog, I have gathered some of the amazing...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7048
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7088
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6741
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5342
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4783
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2997
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2986
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.