I kinda feel like Donald Trump right now -- I either have not enough class, or too much for people to understand...
I'm probably approaching things the wrong way, so I'm here to ask the PerlMonks.
I'm building a webapp in mod perl that, for the sake of this posting, is functionally similar to a messageboard. It has users, they can view pages, register with the system, and post information.
Right now, the structure is like this:
myPackage
myPackage::User
myPackage::User::Register
myPackage::Page
myPackage::Page::Registration
I'm trying to figure out how to handle the user registration page.
At the moment, the page content and logic is in Page::Registration, and the user functions are in User::Register (ie, $this->register(), $this->validateEmail() )
That approach seemed the most logical -- before I started working on it.
Now I'm in the midst of development, and I want to break things. myPackageUser handles all of my session checking and cookie processing, not to mention other things. The first thing i do - whether I have a registered user or a non-logged in visitor -- is make a new myPackage::User.
For my sanity though, I want to keep certain functions separate from levels of the user. All users have the session/cookie processing -- so thats happy. But not all users will have registration/posting functions. So I created Register and Privileged subclasses
Now I've realized that when I create the user, I won't know if they're registered or privileged or what. So grouping/abstracting these functions failed.
I can't figure out how to morph myPackageUser into myPackageUser::Register -- or even if thats a good idea. Not knowing anything about it, it sounds stupid and messy.
Having all the functions within the user base class sounds stupid and messy too.
So, right now, I've migrated all of the registration functions into the myPackage::Page::Registration class -- and pass in a ref to the user. Thats working for now. But I'm unsure if its the way to go.
I would love some feedback
Am I on the right track now? Was I ever? What would the perlmonks do to fix this? Is there a better way I should have approached this, if so - suggestions please.
THank you all in advance.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.