[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Java more classes=better then one class?

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 27
Thread images: 1

File: gui.png (45KB, 703x449px) Image search: [Google]
gui.png
45KB, 703x449px
Hey Guys I'm working on a Schoolprojekt and there is one guy who beliefs he is a programming GOD, he says that if you use more thant two classes than the program is shit.
Now I'm uncertain about what to do :(
>>
in general its good to split your program in more than one file or rather classes. splitting the project makes it clearer. but it depends on the size of your project in how much classes you split it. the principle of splitting the projekt is called OOP
>>
>>55176356
You can use as few or as many classes as you want. You may even use no classes. What is important is that your code is tested, makes sense and can be followed easily. Splitting your code into multiple files with separate behaviours in each is more important than multiple classes, or multiple functions, etc
>>
>>55176356
That one guy is an idiot then. He is naive and has no experience of the world. He has simply read about refactoring and thinks that omni-classes are powerful. OOP is all about decoupling, more classes usually provide more power to the programmer.
>>
OP here
But I could creat for every methode a class is that than a stupid programm?
>>
Yeah sure I'll write this huge complicated web application with tons of business transactions with TWO FUCKING CLASSES

If I had 0 logic and only had to represent my data models for the ORM I would need a minimum of probably 20 classes for fuck sake

Ask your friend to shut the fuck up please
>>
You use one if you need one, you use 200 if you need 200. Your friend is retard.
>>
>>55176646
That's not what classes represent though. You wouldn't justify a class for a simple method. It depends on your domain. But you may wish to make a generic 'project' class with more specified implantations of 'group project' and 'solo project' as they are all projects. Polymorphism gives you this expressive power.
>>
>>55176705
Would you say that the example in the picture is solved good?
we had to create a little dictionary were we can add words and meaning.
>>
>>55176773
Those appear to be methods. In this instance of you want to make a dictionary, that is a collection/container with methods for access and such. The dictionary structure itself can be a singular class, think similar to vector or List. Dictionaries are usually string indexed. For the GUI this would have other elements for UI etc. But it would utilise the dictionary. It would contain methods for user input and display, and would probably have a member for storing the created dictionary. Look up the UML 2.0 class diagram specification, you'll see what I mean about members and methods and such.
>>
>>55176956
Thanks alot for your reply I'm gonna read me into the UML material and we will see what the teacher thinks about that.(The Project)
By the way this diagram is created directly in BlueJ
>>
You should stop learning java immediately, and try C instead.
It's hopefully going to teach you a little bit about programming in general, and then you can come back to java.
>>
>>55177212
Sorry we have to do Java because it's for school
>>
https://youtube.com/watch?v=o9pEzgHorH0
>>
>>55177226
Learn Go in your free time and show your teacher this thread
>>
Design antipattern: God class
>>
>>55177328
Design antipattern: class
>>
>>55176593
>You may even use no classes.

lol no you can't. this pajeet is using java.
>>
>>55177328
What about entrypoint main?
Gotta be contained somewhere?
>>
>>55176356
Depends more on the program.
But in case of enterprise software, 2 classes will be impossible to do, as you would end up with a single class containing over 1 million lines of codes+.

I assume you have to do something with a GUI and a simple logic from your pic?
In this case you usually have only 2 classes(well unless you count inner classes and anonymous classes), 1 for the model and 1 for view and controller.
>>
You will never be a good programmer if you use OOP. Just try and pull through the classes and learn C in your spare time.
>>
>>55179341
>this memer thinks that C is still relevant
>>
>>55176356
More classes are always better than less in OOP, as long as the classes make sense.
>>
>>55176356
Classes are not the end-all be-all of programming, so he's not a hot-shot for using one. There are languages without classes or objects at all.

Just use as many classes as you need. No more, no less.
>>
A proper program needs only 2 classes: one with the main function and another as a process supervisor to start the rest of the program which is written in haskell
>>
>>55176356
>school project
>BlueJ as the IDE

sounds about right
>>
It's hard to say how many classes you need without knowing what the actual program is suppose to do. Having said that, your friend seems like an idiot. Also, splitting a program into multiple classes works well in team projects since every team member can work on their own class with minimal interference.
Thread posts: 27
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.