Better HN
topnewbestaskshowjobs
Log inSign up

tcoville

7 karma · joined Mar 1, 2011 (15y ago) · 3 submissions

Submissions

comment 2y ago · link · parent

This is a heavily simplified version of what I'm suspecting he's trying to portray, key this wouldn't be useful for utility functions like string manipulation but more business logic being used across similar functions:

  def processOrder():
      # Some common processing logic
      print("Processing the order...")
  
  def placeOnlineOrder():
      processOrder()
      print("Sending confirmation email...")
  
  def placeInStoreOrder():
      processOrder()
      print("Printing receipt...")
  
  # Calls from different locations
  placeOnlineOrder()
  placeInStoreOrder()
Could become:

  def processOrder(order_type):
      # Common processing logic
      print("Processing the order...")
  
      if order_type == "online":
          print("Sending confirmation email...")
      elif order_type == "in_store":
          print("Printing receipt...")
  
  # Unified calls with different flags
  processOrder("online")
  processOrder("in_store")

comment 13y ago · link · parent

I have had this problem as well and of course you can add some superfluous code that fulfills the usage for the import/variable but then you have to remember to clean up that code later (essentially discarding the very helpful checking built into the compiler).

I think they would be better off adding a compiler flag for less strict checking for development.

comment 15y ago · link · parent

Instead requiring all of your friends install the app why not have people add friends by email/cell number. Then on the backend determine if they have an account if they have an account send it through the app otherwise they can just send an email/sms.