473,395 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Advice: How do I...

Hi all,

I'm looking for some advice on how best to achitect the following
requirement.

I'm basically writing a Fantasy Football (FF) Web site, and would like
to have it fully OO and have it using as much inheritance, base
classes, common methods, etc as possible.

My biggest headache that I cant get my head around is how to handle
teams and players. The basic scenario of requirements is:

There are 1+ FF leagues
Each FF leage hase 1+ teams
Each FF team has 11+ players
Each FF player can be either goalie, defender, attacker
Each FF player has a monetery value
Each FF player has a number of points per game
There are X number of games per season
There are X number of seasons

Each player in a FF Team comes from an actual REAL football player
A real player can only exist in one FF league
A real player can be active or inactive (and as such the FF player
inherits from this)
A real player has a number of points per game (if the player is a FF
player, then for the appropriate game the FF player gets the points)

I can work out some base classes, properties and methods, but would
find some technical architecture advice invaluable. Any and all output
I produce will be shared!

Thanks all!

Jul 7 '06 #1
8 1501
Hi George,

Fully-OOP is good. Using "as much inheritance, base classes, common methods,
etc as possible" is not good. The purpose of OOP is to make programming
easier, faster, better organized, and more intuitive. Note that none of
these things is any of the things you mentioned wanting to use. That's
because the things you mentioned are tools. Tools do not dictate, nor are
they requirements. If you were going to build a house, and you had a
26-ounce Framing hammer, would you say that you wanted to use the new
Framing hammer as much as possible? Of course not. You really need to use it
as much as necessary.

The difference here is that "OOP" is a set of tools and principles that
defines a methodology for programming. The methodology is good. The tools it
employs are neither good nor bad, except in the context of what you do with
them. The only reason I mention this is that many people have a tendancy to
get too attached to the tools and methodologies, and take their attention
off of the goals/requirements. You can find yourself a good way down the
garden path if you go that way.

The primary principle of OOP is that programming entities should resemble
and be treated as "real-life things." That is, rather than thinking about
the nitty-gritty details of process and data (when designing), think about
all of these as objects. This is the way we humans typically perceive the
world. Data is (almost) always associated with some "real-life" entity. Your
object model should reflect that association.

Another principle is that objects should "mind their own business." That is,
as much as possible, an object should manage itself, rather than being
managed by something else outside of it. This lessens dependencies, allowing
classes to be reused in a wider configuration of apps, and makes the overall
application much simpler. So, for example, a League has a collection of
Teams, a team has a collection of players, and if a player needs his/her
shoe tied, he/she shouldn't have to have a League tie it for him. But on the
other hand, if a Team needs to remove a player, it is not changing the
player, but the Team; therefore, that is an action that is appropriate for a
Team.

So, applying these principles to your requirements:

You have mentioned a number of entities:

League
Team
Player
Goalie
Defender
Attacker
Game
Season

The first 3 items are fairly straightforward. A League has a Collection of
Teams. Note that I didn't say "a league *is* a collection of Teams." There
is an important distinction there. There may be other aspects to a League
that are not specific to Teams. For example, a League's standing is not part
of a team; it is a property of a League. So, I would create a class that
*has* a Collection of Teams.

A Team has a Collection of players. Same story here.

A Player is a player. Now, you have some decisions to make regarding the
"roles" of a player (Goalie, Defender, Attacker). No doubt you're wondering
whether or not to use a base class "Player" and 3 derived classes. Well,
let's walk through that one. Inheritance is useful when you want to extend a
set of common attributes to several sub-classes with unique attributes. It
is useful when you may want to treat any of the derived classes as if they
were the base class (such as referring to a "Goalie" as a "Player" for the
purpose of incorporating it into a Team). However, if a Player can change
their "role" you would not want to use inheritance, as the Player would have
to change type to make the change. Another principle of OOP is that you only
use a type when the type is not expected to change.

On the other hand, you may be talking about some relatively simple
differences here. What makes a Goalie different than an Attacker or a
Defender? (Pardon me for not having played FF before). If the number of
differences is great, a derived class may be a good idea. OTOH, if it
doesn't make a lot of difference, simply setting a property or 2 in the
Player class may do enough.

In the end, you have to weigh all of the conditions, and make a decision.

As for Games and Seasons, that is another difficult issue. A Game is a
process which involves players, but is a temporary process, and may involve
any number of different players (at least any combination of 2 Teams).
Obviously, as there are multiple Games per Season, a Season would suggest a
class that has a collection of Games. A Game might be thought of as having 2
teams, which would indicate 2 properties. However, how do we link each
player in each team with each Game, for the purpose of playing and keeping
statistics? Since each player can play in many games, and each game can have
many players, in a database we would be talking about a "many to many"
relationship. A "many to many" relationship in a database is achieved by
using an intermediate table, which contains 2 columns, each linked to one of
the parent tables, and whatever other columns may be needed. The scoring
statistics sound like one of those things that would be shared between one
class and another, so that detailed performance for each player can be
obtained, as well as summary performance information for each game.

Therefore, I would think that another class called "PlayerPoints" (or
something like that) be created, which includes a Player and a Game as
properties, and a number that represents the number of points which that
Player scored in that Game. Since each Player participlates in any number of
Games, each Player could have a Collection of Games played, and the
PlayerPoints would be a Collection of each Game. That way, you could create
properties for both the player and the game that can tally up their scores.

I hope this at least provides some ideas for you to think over.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

Big thicks are made up of lots of little thins.
<ge*************@gmail.comwrote in message
news:11*********************@s16g2000cws.googlegro ups.com...
Hi all,

I'm looking for some advice on how best to achitect the following
requirement.

I'm basically writing a Fantasy Football (FF) Web site, and would like
to have it fully OO and have it using as much inheritance, base
classes, common methods, etc as possible.

My biggest headache that I cant get my head around is how to handle
teams and players. The basic scenario of requirements is:

There are 1+ FF leagues
Each FF leage hase 1+ teams
Each FF team has 11+ players
Each FF player can be either goalie, defender, attacker
Each FF player has a monetery value
Each FF player has a number of points per game
There are X number of games per season
There are X number of seasons

Each player in a FF Team comes from an actual REAL football player
A real player can only exist in one FF league
A real player can be active or inactive (and as such the FF player
inherits from this)
A real player has a number of points per game (if the player is a FF
player, then for the appropriate game the FF player gets the points)

I can work out some base classes, properties and methods, but would
find some technical architecture advice invaluable. Any and all output
I produce will be shared!

Thanks all!

Jul 7 '06 #2
Kevin,

I can't speak for George, but I found your post very interesting and
relevant. I often find that I have to guard against the very mistake
you mention - implementing a tool or methodology for the mere sake of
doing so. Thank you for taking the time to offer a bit of good advice
on the matter.

I also found it interesting that when George mentioned a fantasy
football website, I just assumed American football. When your examples
used aspects of European football, I had one of those, "Huh. I never
really thought about it" moments. I am well aware of the different uses
of the term "football", but I had never considered that it only stood
to reason that the "fantasy football" we play in the states therefore
might also mean something different across the pond. :P

Anyway, thanks again for your insight. Might you have any links to
additional resources in the way of entity relationship modelling for
mere mortals? In the past, searches on Google tended to turn up
resources that pertain to much more complex scenarios and methods than
I have typically needed to address.

Rich

Jul 7 '06 #3
Thanks Richard,
I also found it interesting that when George mentioned a fantasy
football website, I just assumed American football. When your examples
used aspects of European football, I had one of those, "Huh. I never
really thought about it" moments.
I didn't realize my examples used aspects of European Football (that would
be soccer, right?). I just threw the same terms back that I heard. Actually,
I'm an American, and "sports-challenged" (never could get into watching
other people play games).
Anyway, thanks again for your insight. Might you have any links to
additional resources in the way of entity relationship modelling for
mere mortals? In the past, searches on Google tended to turn up
resources that pertain to much more complex scenarios and methods than
I have typically needed to address.
Now, that's a challenge. Unfortunately, I spoke out of experience, including
reading quite a lot about the subjects over quite a few years, so I don't
have any links about it specifically. The challenge for me would be to
analyze my method of analysis and report it back accurately. I'm a visual
thinker anyway, so I tend to "see" ideas, which helps in the process. I also
tend to see things in analogies, which is also useful.

So, when I'm looking at a set of requirements, I will often think over the
words that are used to describe the requirements. Often, this will be useful
in itself, as we define requirements the way we think, in terms of objects.
For example:
There are 1+ FF leagues
Each FF leage hase 1+ teams
Each FF team has 11+ players
Each FF player can be either goalie, defender, attacker
Each FF player has a monetery value
Each FF player has a number of points per game
There are X number of games per season
There are X number of seasons
The nouns in the sentences give clues as to what sort of classes are needed
initially. Of course, figuring out the relationships is the hard part. I
tend to work off of a few guiding principles, and derive my specific rules
from them:

1. KISS (Avoid unnecessary complexity)
2. Only requirements drive the solution.
3. Avoid dependencies ("A class should mind its own business")
4. Think about the future (extensibility, future features and versions)
5. Occam's Razor: If it looks like an object, it probably should be one.
6. Use inheritance only when appropriate.
7. Often, a good database structure can suggest classes/relationships.
8. Always think at least twice about any decision.
9. Don't get too stuck on your original plan. Watch for opportunities.
10. KISS (Don't get lost in the process).

There's probably more that I'm not thinking about right now. I should
metnion that I'm from the Agile crowd, so that perspective seems to drive my
thinking quite a bit. However, I should mention that I'm only from the Agile
crowd by coincidence. I was Agile before the term existed. When I found out
about the term, I said to myself "So, that's what you are. Good to know
you've got company." I tend to sketch things out on paper, and use quite a
few notebooks for "thinking out loud."

Don't know if that helps any, but there it is!

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

Big thicks are made up of lots of little thins.
"Richard Carpenter" <ru*******@hotmail.comwrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
Kevin,

I can't speak for George, but I found your post very interesting and
relevant. I often find that I have to guard against the very mistake
you mention - implementing a tool or methodology for the mere sake of
doing so. Thank you for taking the time to offer a bit of good advice
on the matter.

I also found it interesting that when George mentioned a fantasy
football website, I just assumed American football. When your examples
used aspects of European football, I had one of those, "Huh. I never
really thought about it" moments. I am well aware of the different uses
of the term "football", but I had never considered that it only stood
to reason that the "fantasy football" we play in the states therefore
might also mean something different across the pond. :P

Anyway, thanks again for your insight. Might you have any links to
additional resources in the way of entity relationship modelling for
mere mortals? In the past, searches on Google tended to turn up
resources that pertain to much more complex scenarios and methods than
I have typically needed to address.

Rich

Jul 7 '06 #4
Kevin Spencer wrote:
Thanks Richard,
I also found it interesting that when George mentioned a fantasy
football website, I just assumed American football. When your examples
used aspects of European football, I had one of those, "Huh. I never
really thought about it" moments.

I didn't realize my examples used aspects of European Football (that would
be soccer, right?). I just threw the same terms back that I heard. Actually,
I'm an American, and "sports-challenged" (never could get into watching
other people play games).
Right you are. It was George that mentioned the player positions in
soccer terms first. Not sure why I missed that. Ah well. I just found
my own initial reaction interesting, but I digress... :P
The nouns in the sentences give clues as to what sort of classes are needed
initially.
That is typically where I start.
1. KISS (Avoid unnecessary complexity)
Sometimes I feel that term was coined with me specifically in mind. :P
4. Think about the future (extensibility, future features and versions)
This is another area where I tend to get bogged down. Maybe my crystal
ball just needs a good cleaning.
7. Often, a good database structure can suggest classes/relationships.
Interesting. I am typically responsible for designing the databases as
well as the applications they support, and I've always considered it
the other way around - normalize the data structures for efficiency and
rely on the business layer to reflect and support the entities and
their relationships. That approach has just always made sense to me. Of
course, it could just be because my database design skills are just
lacking. ;)
There's probably more that I'm not thinking about right now. I should
metnion that I'm from the Agile crowd, so that perspective seems to drive my
thinking quite a bit. However, I should mention that I'm only from the Agile
crowd by coincidence. I was Agile before the term existed. When I found out
about the term, I said to myself "So, that's what you are. Good to know
you've got company." I tend to sketch things out on paper, and use quite a
few notebooks for "thinking out loud."
I agree. I've not researched it much, but the term, "agile computing",
does strike me as a new name for what people have been doing (or
perhaps *should* have been doing) for some time now.
Don't know if that helps any, but there it is!
You bet. Thanks again.

Rich

Jul 7 '06 #5
Kevin,

This is exactly the kind of advice that I was looking for. Yes you are
correct, I need to seperate my OOP from my tools!

Yes, I was talking about "soccer". However, with good OOP I am sure
that it could be used for other similar team based sports.

I do agree with you in regards to the Database modeling. This is a
good indicator as to possible

As for the different types of players, it doesn't really matter. It's
simply a case that I limit the number of players per type. I.e. Only 1
goal keeper, up to 5 defenders, and up to 5 attackers. However, there
can only be a maximum of 11 players per team. For my purposes, no
player could change 'roles'.

Lastly, I didn't know that M$FT were hiring "Professional Chicken Salad
Alchemist" :-)

George

Jul 10 '06 #6

ge*************@gmail.com wrote:
Kevin,

This is exactly the kind of advice that I was looking for. Yes you are
correct, I need to seperate my OOP from my tools!
On that subject, have a look at test driven development. Once you get
into the rhythm of it, it feels really natural and, while I'm not
fanatical about it (or much else), I now find it completely
indispensable whenever I'm working on something and I don't have an
immediate answer to the question "How is this going to work?".

Properly done, TDD will force you to evolve a sensible OO system little
by little and stop you delving TooDeepIntoTheBagOfTricks

http://c2.com/cgi/wiki?TooDeepIntoTheBagOfTricks

Jul 10 '06 #7
ge*************@gmail.com wrote:
Lastly, I didn't know that M$FT were hiring "Professional Chicken Salad
Alchemist" :-)
They dont. The M$ MVP title doesn't make you a M$ emplyee. :)

http://mvp.support.microsoft.com/mvpexecsum
Jul 10 '06 #8
Hi George,

Glad I could help!

I have never worked for Microsoft. The MVP award is given to NON-Microsoft
professionals that help people with Microsoft issues voluntarily. If I *did*
work for Microsoft, you can bet my tag line would be different! ;-)

In any case, from my experience, *every* good developer is a "Chicken Salad
Alchemist." That is a person that makes Chicken Salad out of Chicken s**t on
a regular basis. There was a time in my career when I looked forward to the
day I wouldn't have to, but it never came! ;-)

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

Big thicks are made up of lots of little thins.
<ge*************@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Kevin,

This is exactly the kind of advice that I was looking for. Yes you are
correct, I need to seperate my OOP from my tools!

Yes, I was talking about "soccer". However, with good OOP I am sure
that it could be used for other similar team based sports.

I do agree with you in regards to the Database modeling. This is a
good indicator as to possible

As for the different types of players, it doesn't really matter. It's
simply a case that I limit the number of players per type. I.e. Only 1
goal keeper, up to 5 defenders, and up to 5 attackers. However, there
can only be a maximum of 11 players per team. For my purposes, no
player could change 'roles'.

Lastly, I didn't know that M$FT were hiring "Professional Chicken Salad
Alchemist" :-)

George

Jul 10 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

75
by: Howard Nease | last post by:
Hello, everyone. I would appreciate any advice that someone could give me on my future career path. Here is my situation: I am a bright Junior in a very well-respected private high school, taking...
5
by: Martin Piper | last post by:
Hi all. I've recently landed myself the position of trainee C++ programmer which I'm extremely pleased about, but also nervous. According to the feedback from the interview, I have a good...
3
by: Andy Dingley | last post by:
I've just started on a new project and inherited a huge pile of XSLT (and I use the term "pile" advisedly !) It runs at glacial speed, and I need to fix this this. Platform is MSXML 4 / ASP ...
11
by: ma740988 | last post by:
I'm perusing a slide with roughly 12 bullets spread across 3 pages. Each bullet reflects 'advice'. I'm ok with all but 1 bullet, more specifically the bullet that states: " Avoid the STL unless...
6
by: J Rieggle | last post by:
Hi there, I am stuck on a problem that relates to eCommerce sites, but isnt ASP.NET specific (sorry). The ecommerce site is working in the UK, and products will be sold in pounds stirling. ...
13
by: Alan Silver | last post by:
Hello, MSDN (amongst other places) is full of helpful advice on ways to do data access, but they all seem geared to wards enterprise applications. Maybe I'm in a minority, but I don't have those...
7
by: John Paul | last post by:
I'm thinking of building an e-commerce site in php. Anyone got any advice in building one? What is the best way to implement a payment system? Are any legal issues involved? Thanks,
232
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first...
3
by: mesut | last post by:
Hi colleagues, I need your advice... I have approx 1,5 years experience with ASP.NET/VB.NET 2005 and I have to switch over into C# 2005 language. I don't have experience with C# 2005...
7
by: SM | last post by:
Hello, I have a index.php template (2 columns). The right columns contains a bunch of links (interviews, poems, etc...) The left columns contains the actual article. So if I click on a link on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.