Go Back   AnandTech Forums > Software > Programming

· Hardware and Technology
· CPUs and Overclocking
· Motherboards
· Video Cards and Graphics
· AMD Video Cards
· Nvidia
· Displays
· 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
· Home and Garden
· Merchandise and Shopping
· For Sale/Trade
· Hot Deals with Free Stuff/Contests
· Black Friday 2015
· Forum Issues
· Technical Forum Issues
· Personal Forum Issues
· Suggestion Box
· Moderator Resources
· Moderator Discussions

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


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, 11:22 PM   #2
Diamond Member
Join Date: Apr 2005
Posts: 3,163

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, 11:23 PM   #3
Diamond Member
Join Date: Apr 2005
Posts: 3,163

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

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, 02:43 PM   #5
clamum's Avatar
Join Date: Feb 2003
Posts: 23,584

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.
\ My Rig /\ World of Warships Stats /\ Heat /\
\ Letterboxd (movies) /
clamum is offline   Reply With Quote
Old 12-16-2012, 08:45 AM   #6
Junior Member
Join Date: Dec 2012
Location: Toronto, Ont, Canada
Posts: 10

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

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 08:36 PM.

Powered by vBulletin® Version 3.8.8 Alpha 1
Copyright ©2000 - 2016, vBulletin Solutions, Inc.