Jump to content

How to program?

Hey guys,

 

This is just a general question, how you go about designing a program.

I am doing an assignment for university which involves writing code in java to make small projects like a mini calculator, a flag drawer, etc.

 

My questions are how do you guys think about building a program?

What questions do you ask yourself when making it?

Do you just get it like a lightbulb moment in the movies?

 

Im using BlueJ IDE btw. I know about a program known as "Scratch". I really like how it visually shows statements and commands, is there an IDE like that but for java?

 

Also if you guys have any tips and tricks involving java and java IDE id like to know them please.

Thank you!

Link to comment
Share on other sites

Link to post
Share on other sites

Just break it down.

 

What do I need the program to do: Calculate Things (As an example, let's say the part we're working at is a calculator)

- What parts does the program need to have to do that?

- - Let's say this is a special button for finding the volume of a sphere

- - - well, the first part for finding the volume of a sphere, is to get all the info. so prompt the user to enter in the radius or diameter.

- - - then, apply the formula to the dimentions the user put in

- - - print out the result

- - - ^^ Program this part, test if it works, and then rinse & repeat for the rest of the program.

 

 

 

QUOTE/TAG ME WHEN REPLYING

Spend As Much Time Writing Your Question As You Want Me To Spend Responding To It.

If I'm wrong, please point it out. I'm always learning & I won't bite.

 

Desktop:

Delidded Core i7 4770K - GTX 1070 ROG Strix - 16GB DDR3 - Lots of RGB lights I never change

Laptop:

HP Spectre X360 - i7 8560U - MX150 - 2TB SSD - 16GB DDR4

Link to comment
Share on other sites

Link to post
Share on other sites

On 5/4/2017 at 2:12 AM, o0NotSoToxicPoisoN0o said:

Hey guys,

 

This is just a general question, how you go about designing a program.

I am doing an assignment for university which involves writing code in java to make small projects like a mini calculator, a flag drawer, etc.

 

My questions are how do you guys think about building a program?

What questions do you ask yourself when making it?

Do you just get it like a lightbulb moment in the movies?

 

Im using BlueJ IDE btw. I know about a program known as "Scratch". I really like how it visually shows statements and commands, is there an IDE like that but for java?

 

Also if you guys have any tips and tricks involving java and java IDE id like to know them please.

Thank you!

Scratch is meant to teach people the basics of programming. It's not something you would use to make a serious program.

 

Like RadiatingLight said, the most important thing is to break it down. One good practice is to modularize programs. If I can separate features from each other and enable or disable them without making it impossible to run the program, it becomes easier to debug, easier to roll back and easier to rewrite if necessary.

You can't do a lot of effective modularization on a tiny CLI calculator, but you can do some. For example, I would separate getting the user input from the calculation.

 

I do get lightbulb moments when I'm working on something very difficult, but it's usually after I've been stuck on something for a while, not because I'm a genius who finds all the answers easily and it has nothing to do with how to design a program.

 

Intellij loves to eat your RAM, but it's the best Java IDE I've used.

Link to comment
Share on other sites

Link to post
Share on other sites

Scratch is just for the basics. You don't make any serious programs with it. But as @RadiatingLight already said, you have to break down the steps you need to go. Modularizing programs is a good practice, but for beginners, this can result in a lot of complexity and code overhead. A simple calculator would be easy to do in one class file. But if you are building a GUI MVC (=Model View Controller) is a pretty common architecture. 

There are a bunch of free powerful Java IDEs out there. IntelliJ was already mentioned, but for a beginner, I'd recommend eclipse. Eclipse is a lot simpler to use if your just starting and the most online tutorials are created using eclipse. But if you already know how to use BlueJ it's fine to keep using it for a while. Since it doesn't offer a whole lot of automatic code generation you are getting a really good feeling on how Java classes/interfaces/etc are actually built. 

Link to comment
Share on other sites

Link to post
Share on other sites

As already mentioned break it down. I sometimes quickly scribble an informal UML diagram to help me get an understanding for what will have to interact with what and how for the program to do what I want it to. Get familiar with and try using some common design patterns like Model-View-Controller, Facades, Observers, Factories, etc. Also for breaking down a program you can go from bottom up or top to bottom in your breakdown. Both have pros and cons so it's a good idea to do a bit of both.

 

 

Basically read a few Software Engineering related books or something.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×