• Post Reply Bookmark Topic Watch Topic
  • New Topic

OOP. simple in theory, complex in creation  RSS feed

 
Matthew Joseph
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With OOP, how in depth are you supposed to go? Am I even understanding correctly? I have no clue! This involves pretty much every post I have made so far.
Heres the setup:
300+ computers, printers, routers, etc
14 branch offices, each on a seperate subnet (192.168.1.0,192.168.138.0, etc)

goal: scan ip ranges, discovering which ones are in use. when a pc is found, get certain info from it(host name, operating system, dns settings, etc). after I
am more comfortable with java, maybe manipulate settings, but just gathering info for now.

So far I have 2 classes:
CommandPrompt, which has 2 methods so far- pinging an ip, and retrieving systeminfo of that ip.
Search, which has 2 methods so far- a search for a generic string, and an operating system search.

I made a mind map in the beginning, and had these classes, along with a Branch object and pc object. But as I have worked on it, I realize how much I didn't think about.
Am I doing this right? should everything be seperate, or should most of these methods be part of one of the objects? Should I be starting on the big picture, and working
down to the details, or start small and work toward the big picture? Generally, any tips or pointers about my first OOP?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37462
537
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew,
It's hard to create an OOP program for a very simple program. It's still ok to practice though.

I see an object that is calling out from your description. Pc or SystemInfo. That's something that naturally has attributes. And it is something you use in multiple places.

When you are looking at a problem, try to look for the "things." That often provides clues as to the objects.
 
Matthew Joseph
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the tip Jeanne. the only coding experience i have had was pascal in highschool, and that was in '97! since i am starting java, i really want to do it the right way and not have to break bad habits later
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66304
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing I do is to look at the requirements description and pick out the nouns. These are all possible classes. For example, in your description:
300+ computers, printers, routers, etc
14 branch offices, each on a seperate subnet (192.168.1.0,192.168.138.0, etc)

goal: scan ip ranges, discovering which ones are in use. when a pc is found, get certain info from it(host name, operating system, dns settings, etc).

I see: Computers, Printers, Routers (all of which are Devices), Branch Office, Subnet, and so on.

This list is where I start designing the class hierarchy.
 
Matthew Joseph
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
awesome. the noun thing makes a lot of sense. now, should objects be broken down into pc-router-printer, or should it be a device object with a type attribute?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!