Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

You start with a story and some paper index cards ( Class Responsibility Collaboration(crc) cards ) because there is (no isa in crc)

marinersk has the right idea, you should always start by asking questions, too many tutorials jump straight into writing code ... how can you write code before you know what its supposed to do?

Similar to what marinersk is trying to convey but the important difference is you don't design around attributes -- otherwise you end up with a bag of attributes -- you're designing about responsibility, then the actions(methods) needed for such responsibility

So this is what you currently have

Movies::LookUp
Responsibilities: (what the class does)
  • retrieve Movies
  • retrieve info about movies
  • retrieve relationships
  • about
  • basis
  • crossovers
  • display_movie
  • end_year
  • franchise
  • franchise_hash
  • genre
  • genre_hash
  • get_crossover
  • media
  • mini_parts
  • movie
  • movie_hash
  • movie_is
  • movie_links
  • options
  • own
  • run_time
  • search_link
  • series
  • series_hash
  • series_text
  • start_year
  • years_running
Collaborations: (related objects)
  • Movies::Display
Movies::Display
Responsibilities: (what the class does)
  • be confused about your purpose :)
  • get_season_title
  • return_link
  • like
  • print_series
  • print_program
  • print_season
  • unquote_parts
  • get_episode
Collaborations: (related objects)
  • Movies::LookUp
Movie
Responsibilities: (what the class does)
  • I maintain information about a Movie
  • I broadcast change notifications
Collaborations: (related objects)

So you can see that some some reorganization is in order , and you need to step back and tell a story (and write it down), then create some class/responsibility/relationship cards and see how they fit together

One class has too much responsibility and needs to be split up into two maybe three classes

The other class is confused a little bit about its purpose

And a third class is missing ... the classic pattern is MVC, you have Model (or the makings of a model), you have the beginning of a View, but there is no Controller

For another comparison jeffa also starts with inheritance based on attributes, but its too early in design phase to think about attributes, esp inheritance based on attributes , inheritance isa crock best avoided

Its like almost every tutorial on MVC... just takes for granted the questions what is the responsibility / what should it do, and jumps straight into bag of attributes, but you're supposed to hide the data behind an interface

So here is the best next step you can take, tell a story, make some index cards, see how they fit together to help tell the story, and then share your thoughts with us, this is the beginning :)


In reply to Re: How do I go from procedural to object oriented programming? ( ooad ood modeling crc) by Anonymous Monk
in thread How do I go from procedural to object oriented programming? by Lady_Aleena

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-03-29 06:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found