1

I have to create a Media Library for a tasksheet, which stores Peoples Information (Normal People, Artists, Bands) and Media(Audio [audio length - type String] Video[Size - type String])

I started creating a MediaContainer Class, which (through ArrayList) allows me to store information of type String. So I thought I would simply create two classes (MediaContainer which is supposed to hold the data, and Information Class which has all the methods to fill it - I'm a beginner so extra question: am I doing it right?)

The Help i really need is assurance or advice from more experienced users in a form of feedback (so i know i'm heading the right way). This is how far I am -

import java.util.ArrayList;

public class MediaContainer {

    ArrayList<String> Media = new ArrayList<String>();

    public MediaContainer(String addmedia) {
        Media.add(addmedia);
        System.out.println("this is the list :"+Media);
    }
}

How should I proceed? Many thanks in advance!

4
  • 2
    I assume Artists != Normal People. ;) Commented Jan 10, 2013 at 10:56
  • Artists > Normal People ? Commented Jan 10, 2013 at 11:00
  • Looks fine. You can be a little more confident I think. Commented Jan 10, 2013 at 11:00
  • Write private List<String> media = new ArrayList<>(); -- respect Java naming conventions, program to interfaces, use proper encapsulation. Also, I don't find your constructor meaningful: it accepts only one list element. Commented Jan 10, 2013 at 11:03

1 Answer 1

2

I would write a simple unit test to show you can add the information you need and retrieve it.

I would also try to;

  • follow Java Coding Conventions e.g. camelCase variables.
  • make fields final and private where possible.
  • use interface instead of concrete types for collections where possible e.g. List
  • I assume you will need a custom class Media to record the information associated with media. i.e. one String will not be enough.
Sign up to request clarification or add additional context in comments.

2 Comments

And I would also not separate Artists from Normal People. ;)
@PeterLawrey.. Can you help me out in this question: - stackoverflow.com/questions/14252520/… if you haven't already seen it. I'm afraid that question is now burried deep, and I haven't got any convincing answer :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.