Go Back   AnandTech Forums > Software > Programming

Forums
· Hardware and Technology
· CPUs and Overclocking
· Motherboards
· Video Cards and Graphics
· Memory and Storage
· Power Supplies
· Cases & Cooling
· SFF, Notebooks, Pre-Built/Barebones PCs
· Networking
· Peripherals
· General Hardware
· Highly Technical
· Computer Help
· Home Theater PCs
· Consumer Electronics
· Digital and Video Cameras
· Mobile Devices & Gadgets
· Audio/Video & Home Theater
· Software
· Software for Windows
· All Things Apple
· *nix Software
· Operating Systems
· Programming
· PC Gaming
· Console Gaming
· Distributed Computing
· Security
· Social
· Off Topic
· Politics and News
· Discussion Club
· Love and Relationships
· The Garage
· Health and Fitness
· Merchandise and Shopping
· For Sale/Trade
· Hot Deals with Free Stuff/Contests
· Black Friday 2013
· Forum Issues
· Technical Forum Issues
· Personal Forum Issues
· Suggestion Box
· Moderator Resources
· Moderator Discussions
   

Reply
 
Thread Tools
Old 12-01-2012, 07:35 PM   #1
jeisma
Junior Member
 
Join Date: Dec 2012
Posts: 1
Default OOP - Class Design

Hi!

I'm in very early stages of OOP. Coming from a procedural programming, I'm starting to see the change in mindset when designing my application.

My first project:

Convert numbers, date, time values in different languages. Language is not known until run time.

This is how I designed my classes.

Interface ILang. With methods num_to_words(), date_to_words(), time_to_words().

And above interface implemented by these classes: French. English. Spanish. German...

I'm not comfortable about this design. Maybe I should have a class Number, or Date, or Time?

How would you design your classes? Which pattern works best with this scenario?


Thank you!
jeisma is offline   Reply With Quote
Old 12-02-2012, 10:22 PM   #2
douglasb
Diamond Member
 
Join Date: Apr 2005
Posts: 3,163
Default

Presumably, the "number", "date", "time", etc. would use the classes that are built in to most languages (Integer, for example). Or they would just be primitive types. At any rate, you are over-complicating it. You have a generic ILanguage and however many classes that implement it. For what you are trying to do, you really don't need to abstract it any further than that.
douglasb is offline   Reply With Quote
Old 12-02-2012, 10:23 PM   #3
douglasb
Diamond Member
 
Join Date: Apr 2005
Posts: 3,163
Default

What programming language?
douglasb is offline   Reply With Quote
Old 12-03-2012, 12:09 AM   #4
beginner99
Platinum Member
 
Join Date: Jun 2009
Posts: 2,148
Default

Dates, times, timezone etc are extremely problematic and not easy at all. Save your time it has been done and I very strongly suggest using a standard library for that problem regardless of language.
beginner99 is offline   Reply With Quote
Old 12-11-2012, 01:43 PM   #5
clamum
Lifer
 
clamum's Avatar
 
Join Date: Feb 2003
Posts: 21,533
Default

For your project, I'd say what you have is decent. No need to over-think it like douglasb metioned.

How about trying a simple game, like maybe Blackjack? Or check beginner C# of Java books/tutorials for ideas on simple apps to get the hang of OOP.
__________________
\ Battlefield 4 Stats /\ Heat /
clamum is online now   Reply With Quote
Old 12-16-2012, 07:45 AM   #6
eyahaloms
Junior Member
 
Join Date: Dec 2012
Location: Toronto, Ont, Canada
Posts: 10
Default

I think its a good design. And I've been using C++ object oriented for 12 years.
Basically the client gets a ILang pointer (in Run time), which is basically a derived class
and does the conversion.
eyahaloms is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 01:50 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.