SophieMay16
Badges: 13
Rep:
?
#1
Report Thread starter 1 year ago
#1
Hi,

I am considering doing some sort of quiz for my a level computer science coursework and was wondering if anybody knows how to incorporate object oriented programming into this?

Thank-you
0
reply
winterscoming
Badges: 19
Rep:
?
#2
Report 1 year ago
#2
You can pretty much apply object-oriented programming to anything - The best way to think about object-oriented programming is just to think of it as a way of how you decide to split up your code into logically separate 'pieces'.

Start by look at the different things that your program would do and use that as a way to divide up the program. Ideally, a class in OO programming is just a group of methods which all relate to each other.

So, for a quiz program, start by taking a look at some popular apps and get a few ideas about different features and capabilities of the app, then that could lead you towards being able to think in terms of objects.

For example, have a look at the features of this quiz app: https://itunes.apple.com/gb/app/quizup/id718421443?mt=8

So, in terms of features, think of stuff that a user can do in an app like that, and things which the app would do itself - for example
- Logging in / Logging out
- Viewing/changing own profile, or finding/viewing other users' profile(s)
- Finding a quiz from a list of quizzes
- Starting a quiz against another user
- Answering a question during a game
- Storing users' activity in a database (their game history and answers for example)
- Calculating scores, allowing users to see the scores on a board

There's probably other stuff too like password resetting, users messaging each other.

How you could possibly apply OO Programming to those kinds of things is to think of functionality which seems logically related to each other and group them up - those groupings become classes:

For example:
- Authenticator class which checks the identity of a user and their password, providing you with Login and Logout methods
- Class which supports Reading and Modifying a user's own profile data
- Class which supports finding other users' profiles and having a limited way of viewing their data, without the ability to modify other users' profiles.
- "Database Repository" class(es) for performing Query/Modify operations to/from the database - e.g. searching a quiz catelogue based on category or title

The term 'repository' crops up a lot in UI apps -- people often make repository classes which are solely responsible for holding logic related to database queries and database connections so that the rest of the app doesn't need to contain details about the database connection or database queries and tables.

Another thing to think about too -- it's always a really good idea to keep your 'front end' UI stuff totally separate away from database stuff! Again, OO programming is all about splitting things up, and the classes in your app which have methods for things like button clicks, or painting on the screen, or anything else related to the UI shouldn't contain any methods which dabble with SQL or database connections -- UI stuff is a totally separate concern compared with Database stuff, and it makes sense for them to be in their own separate classes

Also don't forget that whenever you're working with databases you are also bound to get objects which just have fields and no methods - that's OK as well, not all classes need to have methods, and especially when you have data "objects", e.g. you might end up with a "User" object that only contains fields like ID, username, password -- and that's OK because those objects are for keeping data in-memory before and after a database query - those data objects don't need to contain logic/methods.

In any case, don't worry too much about your design when you're first starting. You should instead focus on making sure you have a clear set of objectives and success criteria - the rest of your project will rest on top of whether you have got a really good, detailed, objective, measurable and testable set of objectives. Everything stems from those. Other things like UI mock-ups, test scenarios, and a clear breakdown of the actual features in your app will all need to relate back to the objectives -- for example, an objective related to user login and security might lead to a user authentication feature, with different levels of authorisation permissions depending on whether that user's role is guest, admin, member, etc.
1
reply
SophieMay16
Badges: 13
Rep:
?
#3
Report Thread starter 1 year ago
#3
(Original post by winterscoming)
You can pretty much apply object-oriented programming to anything - The best way to think about object-oriented programming is just to think of it as a way of how you decide to split up your code into logically separate 'pieces'.

Start by look at the different things that your program would do and use that as a way to divide up the program. Ideally, a class in OO programming is just a group of methods which all relate to each other.

So, for a quiz program, start by taking a look at some popular apps and get a few ideas about different features and capabilities of the app, then that could lead you towards being able to think in terms of objects.

For example, have a look at the features of this quiz app: https://itunes.apple.com/gb/app/quizup/id718421443?mt=8

So, in terms of features, think of stuff that a user can do in an app like that, and things which the app would do itself - for example
- Logging in / Logging out
- Viewing/changing own profile, or finding/viewing other users' profile(s)
- Finding a quiz from a list of quizzes
- Starting a quiz against another user
- Answering a question during a game
- Storing users' activity in a database (their game history and answers for example)
- Calculating scores, allowing users to see the scores on a board

There's probably other stuff too like password resetting, users messaging each other.

How you could possibly apply OO Programming to those kinds of things is to think of functionality which seems logically related to each other and group them up - those groupings become classes:

For example:
- Authenticator class which checks the identity of a user and their password, providing you with Login and Logout methods
- Class which supports Reading and Modifying a user's own profile data
- Class which supports finding other users' profiles and having a limited way of viewing their data, without the ability to modify other users' profiles.
- "Database Repository" class(es) for performing Query/Modify operations to/from the database - e.g. searching a quiz catelogue based on category or title

The term 'repository' crops up a lot in UI apps -- people often make repository classes which are solely responsible for holding logic related to database queries and database connections so that the rest of the app doesn't need to contain details about the database connection or database queries and tables.

Another thing to think about too -- it's always a really good idea to keep your 'front end' UI stuff totally separate away from database stuff! Again, OO programming is all about splitting things up, and the classes in your app which have methods for things like button clicks, or painting on the screen, or anything else related to the UI shouldn't contain any methods which dabble with SQL or database connections -- UI stuff is a totally separate concern compared with Database stuff, and it makes sense for them to be in their own separate classes

Also don't forget that whenever you're working with databases you are also bound to get objects which just have fields and no methods - that's OK as well, not all classes need to have methods, and especially when you have data "objects", e.g. you might end up with a "User" object that only contains fields like ID, username, password -- and that's OK because those objects are for keeping data in-memory before and after a database query - those data objects don't need to contain logic/methods.

In any case, don't worry too much about your design when you're first starting. You should instead focus on making sure you have a clear set of objectives and success criteria - the rest of your project will rest on top of whether you have got a really good, detailed, objective, measurable and testable set of objectives. Everything stems from those. Other things like UI mock-ups, test scenarios, and a clear breakdown of the actual features in your app will all need to relate back to the objectives -- for example, an objective related to user login and security might lead to a user authentication feature, with different levels of authorisation permissions depending on whether that user's role is guest, admin, member, etc.
That is so helpful, thank-you so much!
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

How do you feel about your grades? Are they...

What I expected (4)
13.79%
Better than expected (7)
24.14%
Worse than expected (18)
62.07%

Watched Threads

View All