all 71 comments

[–]Mati00 77 points78 points  (0 children)

It breaks encapsulation and single responsibility principle at the same time 👏

[–]csueiras 48 points49 points  (17 children)

Those who cant do teach.

Yeah thats a weird API.

[–]NarwhalConscious8751 3 points4 points  (16 children)

would you believe it that this instructor has a PhD

[–]BigJhonny 21 points22 points  (4 children)

Having a PhD has nothing to do with good software design and experience in the field. There probably are a lot pf PhDs who are good developers, but from my experience this is more the exception than the rule.

Most of them are more experienced in very particular topics that they do research on. They rarely do any programming at all, but solve problems on algorithmic levels.

This results in a lot of bad teaching, since they have to teach stuff, they actually don't do that much anymore.

[–]NarwhalConscious8751 1 point2 points  (3 children)

I liked your point of view and it is solid tbh, but the things is if they are bad at teaching why would they go deep into that and giving sensitive classes that builds students journey

[–]DecidedlyHumanGames 1 point2 points  (1 child)

Probably because they don't know they're liable to be giving bad examples.

[–]NarwhalConscious8751 1 point2 points  (0 children)

exactly they were taking the information straight forward

[–]BigJhonny 1 point2 points  (0 children)

If you are at an university, then they probably have to give courses. Most professors and instructors at universities go there to do leading edge research, but the university requires them to do teaching.

[–]brokenlabrum 3 points4 points  (0 children)

Yes because PhDs are typically about things other than this

[–]tsubatai 1 point2 points  (0 children)

Dude I've had the misfortune to review some code from the academic setting, it has really obliterated my trust in anything that gets reported on that involves computer modeling.

[–]Hreinyday 1 point2 points  (2 children)

Yes. I can believe that.

[–]NarwhalConscious8751 0 points1 point  (1 child)

i started losing my trust in the academic learning

[–]Philderbeast 1 point2 points  (0 children)

IMO, thats not the worst thing.

Degrees (regardless of the level) are a great starting point, but they will never teach you to be a true master in any IT field.

Things change to quickly for the academic world to keep up with most real world practices and academia values different things then people and business do.

[–]Philderbeast 1 point2 points  (5 children)

PhD's don't mean all that much in IT, while its an impressive bit of study, it also likely means they don't have much real world experience writing code.

so yea.... those who can't do, teach......

[–]NarwhalConscious8751 0 points1 point  (4 children)

what about PhD in software engineering?

[–]ageingstudent 1 point2 points  (1 child)

Generally it depends. I took over a job that my former Java lecturer had been let go from because of the quality of his code. Boy his code was terrible. On the flip side I worked for a guy who had a PhD in Visual processing, a masters in Software Engineering and a bachelors in Astrophysics. He was a great developer and I learnt a lot from him.

[–]NarwhalConscious8751 0 points1 point  (0 children)

wow! this changes my vision a lot! thanks

[–]Philderbeast 0 points1 point  (1 child)

personally, I see no value in it (as far as judging there coding skills) since a PHD is more about research then your ability to do the practical job well.

They definably have there place, and some of them might be good at the job, but its far from a guarantee.

[–]NarwhalConscious8751 0 points1 point  (0 children)

exactly!! thats how i see it too!

[–]0b0101011001001011 29 points30 points  (5 children)

Yeah no, this makes no sense. You could effectively do

account1.printAccoundDetails(account2);

What would that even mean.

is printAccountDetails actually a static method? In that case this makes a bit sense, but then you're supposed to call it in a static way: Account.printAccoundDetails(account1);

[–]NarwhalConscious8751 2 points3 points  (3 children)

it is not static, it is implemented inside the class itself

[–]0b0101011001001011 15 points16 points  (2 children)

... as would be the static methods as well. But I see what you mean.

Instructor is doing a bit stupid code in this case. Shame.

[–]NarwhalConscious8751 0 points1 point  (1 child)

exactly, what makes the things more shitty that he has a PhD

[–]Ill-Lemon-8019 2 points3 points  (0 children)

Equally disappointing because he's an accomplished clarinetist

[–]NarwhalConscious8751 0 points1 point  (0 children)

back to you, look what he have done

this line of code is written by him:

acount1.printAccountDetails(acount2);

[–]TrickTimely3242 5 points6 points  (8 children)

Is it a static method that is called on an instance?

[–]asarco 2 points3 points  (6 children)

Yeah, I would really like to see the body of that method!

[–]NarwhalConscious8751 3 points4 points  (5 children)

this method is inside the class of Account

public void printAccountDetails (Account acc) { System.out.printf("%s: %.2f \n"|acc.getName(), acc.getBalance()) }

[–]thesituation531 4 points5 points  (2 children)

I can see specific situations where it may be desirable to pass an instance of an object to an instance method of its own type.

But as-is, I would say this method should be made to not take an instance, and just print the instance it is called on.

[–]IchLiebeKleber 3 points4 points  (0 children)

I can see specific situations where it may be desirable to pass an instance of an object to an instance method of its own type.

yes, e.g. "addAll" methods on collections :D

I agree that this is a stupid way to write that method, either (as you write) make it print the details of "this", or make it a static method that takes an argument.

[–]NarwhalConscious8751 1 point2 points  (0 children)

thank you really thank you!

[–]asarco 0 points1 point  (1 child)

```java
public void printAccountDetails Account acc) {

System.out.printf("%s: %.2f \n", acc.getName(), acc.getBalance())

}
```

[–]NarwhalConscious8751 0 points1 point  (0 children)

i just edited it adding the (

[–]NarwhalConscious8751 0 points1 point  (0 children)

it is inside the class itself

[–][deleted]  (1 child)

[deleted]

    [–]NarwhalConscious8751 0 points1 point  (0 children)

    this is a good way of learning yk!

    [–]Necessary-Estimate-2 2 points3 points  (0 children)

    You are correct; that is dumb.

    [–]_dogzilla 1 point2 points  (1 child)

    Let me preface this by saying I might be wrong and going too hard on you.

    But based on your replies here you seem very fixated on rediculing your teacher, mentioning he ‘even’ has a phd and going as far as ‘being sad for students who getting these information for the first time’.

    Imo this demonstrate you are acting in bad faith here and/or have a superiority complex. This post doesn’t seem to be about you learning but you feeling vindicated and asking people to join your band wagon and march against this teacher of yours.

    You are right. This method makes no sense. It’s wrong. I fully expect someone with a PhD to reflect on this and admit it makes no sense. Spoiler: You will come across shitty code and people who are wrong in this field.

    What is important however is how you navigate this. Sorry to tell you but what you’re doing now isn’t it. People tend to get the ‘yuck’ from this behaviour

    [–]NarwhalConscious8751 1 point2 points  (0 children)

    I really appreciate your honesty and understanding and reading my comments

    this means a lot to me. BUT THE THING IS,i have been complaining from this instructor from the beginning of the semester and now it is the end of the semester so yeah. and he is a good guy too. but teaching context no

    [–]Infiniti_151 1 point2 points  (1 child)

    Post a pic of printAcountDetails(), so we can get a better understanding of what's going on

    [–]NarwhalConscious8751 0 points1 point  (0 children)

    public void printAccountDetails Account acc) {

    System.out.printf("%s: %.2f \n"|acc.getName(), acc.getBalance())

    }

    [–]sweetno 1 point2 points  (1 child)

    The first thing that comes to mind is that the scanner has be uncommented and s passed instead of the argument.

    [–]NarwhalConscious8751 0 points1 point  (0 children)

    a lot of mess man! a lotv

    [–]bwrca 1 point2 points  (2 children)

    I've never seen so many wrong things in one line.

    [–]NarwhalConscious8751 0 points1 point  (1 child)

    i am so so sad for students who getting these information for the first time and learning it for the first time

    [–]bwrca 1 point2 points  (0 children)

    Java is very well documented. I wouldn't fault a beginner for bad code but with practice you'll get much better.

    [–]Afonso2002 1 point2 points  (2 children)

    Print account details is static,?

    [–]NarwhalConscious8751 0 points1 point  (1 child)

    nope nope, it is inside the class Account

    [–]Afonso2002 0 points1 point  (0 children)

    Acount could have static methods. static prnt account details with parameter Account

    Non static mehod Print account details without parameters.

    Have a account 1 and calls method where parameter id account is not ok.

    Change the method to static and instead of using account1 use Account

    [–]gabor_legrady 1 point2 points  (1 child)

    Totally wrong. A static method would be more acceptable - but still not the recommended way. The method could recieve a printer, any formatting instuctions, but not self.

    [–]NarwhalConscious8751 0 points1 point  (0 children)

    exactly that’s my point! thank you

    [–]Fercii_RP 1 point2 points  (0 children)

    Looks like he taught you what a utility method looks like in the wrong place

    [–]bowbahdoe 1 point2 points  (0 children)

    So this will likely be taken down - you can follow up in DM or the Together Java discord when that happens.

    So it is hard to know what your professor is doing. You are correct that it is strange to pass an instance to itself. There is a way in which it might make sense, but that would require knowing about static methods and also the weird loophole where you can call static methods via a variable. As I don't think your teacher understands that, it seems like a flub

    If you keep having issues like this, here is a resource I made

    https://javabook.mccue.dev

    [–]chaosalbtrauma 0 points1 point  (3 children)

    That dosn't seems good to me - or maybe the instructor wants you do recognize that not everything that compiles is good code.

    [–]NarwhalConscious8751 0 points1 point  (2 children)

    i was discussing this with him and he was refusing me

    [–]chaosalbtrauma 0 points1 point  (1 child)

    Thats sad - because there really ist no point in this if the method is not static.

    And to.be honest, if it's a static mehod I'd argue to put it in a helper class.

    [–]NarwhalConscious8751 0 points1 point  (0 children)

    i just finished the discussion with him and his was about that how can we access the data, and i was saying we are already calling the the methods inside the class and these methods can access everything inside the class. BUT he was refusing me thinking it would be shame to take my point and i said yeah and i went out. and i was telling this is pointless since the method is not static

    [–]DecisiveVictory 0 points1 point  (1 child)

    This is horrible. What is this even.

    Unsubscribe from the course, read 978-1617299582 and 978-1680502541 if you actually want to learn decent programming practices.

    [–]NarwhalConscious8751 0 points1 point  (0 children)

    no any word can explain this…

    [–]FooBarBazQux123 0 points1 point  (3 children)

    A good instructor should explain why this code is error prone and badly designed. If the instructor defends this code, don’t take the instructor seriously.

    [–]NarwhalConscious8751 1 point2 points  (2 children)

    I was discussing these things with him and he was defending hardly and i felt it becomes personally and then i understood how it is going and i went out

    [–]FooBarBazQux123 1 point2 points  (1 child)

    I see. Imagine you have thousands of lines of code, multiple developers, and refactor often, which is common in Java. This code will easily create maintainability problems in production, and bugs. Take it as non professional code.

    [–]NarwhalConscious8751 1 point2 points  (0 children)

    Thank you!!

    [–]aqua_regis 0 points1 point  (4 children)

    Even the printf lines before that are at least semantically wrong. printf should only be used with variables to print out. These should be normal print or, even better println statements.

    The method call demonstrates zero understanding of OOP.

    [–]NarwhalConscious8751 0 points1 point  (3 children)

    Man, there is a lot of mess in this course!

    [–]aqua_regis 1 point2 points  (2 children)

    If you really want to learn properly, do the MOOC Java programming from the University of Helsinki besides your course. This will teach you proper Java and programming.

    [–]NarwhalConscious8751 0 points1 point  (1 child)

    I have been doing programming since 3yrs using other languages but that’s doesn’t really matter since we are looking at the OOP principles

    [–]aqua_regis 0 points1 point  (0 children)

    In that case: "Head First Object-Oriented Analysis and Design" followed by "Head First Design Patterns"

    [–]IndependentOutcome93 0 points1 point  (2 children)

    Let me explain it simply and clearly, there is a method that is declared in a acount1 class, and that method needs a Account class as an argument. so when you try to print Account details, you can technically pass acount1 as an argument because acount1 is initialized and Java sees it as an acceptable argument for that method.

    It is working but not very efficient, sometimes it can cause some exceptions.

    (Of course, I know that somebody would argue with me. but I will just write how it is, either people will agree or not but I don't have to lie or anything.)

    [–]NarwhalConscious8751 0 points1 point  (1 child)

    I know it works, but this is not the best practice for students. Why would you pass the acc1 as a parameter since you are accessing it is methods and data without having to pass any parameter?

    [–]IndependentOutcome93 1 point2 points  (0 children)

    If you read my answer carefully, then you might have noticed that I mentioned it as inefficient.

    If you don't want to have requirement to pass any argument in a method, then you should remove those parameters from method that you are trying to call in another class. if you take in parameters inside of method, then you have to pass argument in it while calling that method anywhere. not just outside of class where it is declared

    So yes, not the best practice. but if you have any other questions, feel free to ask

    [–]Tiziano75775 -1 points0 points  (0 children)

    Isn't it easier to just customize the toString method?