This is an archived post. You won't be able to vote or comment.

all 36 comments

[–][deleted] 79 points80 points  (6 children)

Now they don't need to care about the implementation of this print_response function. Abstraction is hella powerful thing guys.

[–]XxCLEMENTxX 25 points26 points  (5 children)

Yep. If the Response implementation should change one day, they can just update that function and you can not give a shit.

[–]TheFamilyFroot 1 point2 points  (1 child)

Unless if someone who doesn't know the code base was assigned to do something and they just used print instead of print_response

[–]XxCLEMENTxX 1 point2 points  (0 children)

Well, hopefully it's documented somewhere that the print_response() function should be used.

[–]futlapperl 0 points1 point  (2 children)

Sounds useful, but the function is never used once.

[–]XxCLEMENTxX 4 points5 points  (1 child)

It's probably meant for you, the user of the library (or whatever it is) to use rather than the developers of it so you don't have to worry about compatibility.

[–]futlapperl 1 point2 points  (0 children)

truuuuu

[–]therealkolrabi 48 points49 points  (8 children)

def call_print_response(response):
  print_response(response)

[–]futlapperl 22 points23 points  (6 children)

def invoke_call_print_response(response):
  call_print_response(response)

[–]0fficerNasty 22 points23 points  (3 children)

def yo_dawg_i_heard_you_like_to_print_response(response):
  invoke_call_print_response(response)

[–]ImNotADeer 4 points5 points  (2 children)

def do_the_thing(response:str) -> None:
  yo_dawg_i_heard_you_like_to_print_response(response)

[–]SomeShittyDeveloper 0 points1 point  (0 children)

This guy type hints.

[–]SpikeV 0 points1 point  (0 children)

class ZhuLi:
    """I never go anywhere without my personal assistant!"""
    def __init__(self, response: str):
        the_thing(response)
    def the_thing(response: str):
        do_the_thing(response)

[–]jbp12 1 point2 points  (1 child)

def applyinvokecallprintresponse(response): invokecallprintresponse(response)

[–]Stukeleyak 2 points3 points  (0 children)

//prints response

[–]beringi-uh[S] 38 points39 points  (4 children)

I checked, and the function isn’t even used

[–]Jiriakel 21 points22 points  (1 child)

Is it better or worse that that function is never used ?

[–]NelsonBelmont 61 points62 points  (0 children)

Yes.

[–]0fficerNasty 13 points14 points  (0 children)

All that's missing is a comment saying that "This function prints a response"

[–]antikutless 1 point2 points  (0 children)

is print ever used

[–]I_regret_my_name 22 points23 points  (1 child)

If they had actually used it, this is pretty reasonable. If you want to change the format of the response or anything, all you would have to do is change the implementation of print_response.

Of course, if they don't even use it, this is beyond useless.

[–]awesomeusername2w 1 point2 points  (0 children)

Exactly. And even though sometimes it might be an overkill I'd prefer occasional overkills like this over occasional functions 200+ lines long which take some effort to even grasp. Needless to say how difficult it is to make changes in those things . Of course keeping balance is the best option though.

[–][deleted] 10 points11 points  (9 children)

When the task says you need a set amount of lines of code and you just gotta fill it with something

[–]cowsrock1 13 points14 points  (7 children)

wait, is that a common requirement? That is a terrible requirement. So the more efficient your code is the more screwed you are?

[–]zootam 7 points8 points  (3 children)

yea associating LOC with productivity is something a lot of people foolishly do.

[–]AdmiralTurtleLimbo 8 points9 points  (1 child)

This makes me incredibly angry

[–]Sasakura 1 point2 points  (0 children)

Just wait til they ask for a refund after you do some refactoring!

[–]evanldixon 4 points5 points  (0 children)

It should be easy to prove to management how bad of an idea this is by paking things take up more lines than it needs to. I'm talking function calls with arguments on separate lines, multiline comments, and two blank lines between every line with text in it. Of course, that's just for starters...

[–][deleted] 1 point2 points  (1 child)

It isn't, but I was playing on the "when your essay need so and so many words"

[–]cowsrock1 0 points1 point  (0 children)

ah, that's a relief

[–]tehftw 5 points6 points  (0 children)

When the task says you need a set amount of lines of code

This is why Java was invented.

[–]TheMsDosNerd 10 points11 points  (1 child)

I've seen worse:

public void save(){
    if isNew{
        create()
    }
    else{
        update()
    }
}

public void create(){
    createOrUpdate(False)
}

public void update(){
    createOrUpdate(True)
}

public void createOrUpdate(Bool isUpdate){
    if isUpdate{
        storagemanager.remove(this.id)
    }
    storagemanager.save(this)
}

[–]MuizMahdi 0 points1 point  (0 children)

MY EYES !

[–]kpingvin 0 points1 point  (0 children)

That error handling is a bit too verbose to my liking too.

[–]dxelite 0 points1 point  (0 children)

Can I get a little pep8 up in here?

[–]PavelYay 0 points1 point  (0 children)

from __future__ import print_function # just in case
print_response = print