Python Forum
Class variable / instance variable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Class variable / instance variable
#9
(Jul-27-2020, 02:57 PM)deanhystad Wrote: It is not a common practice to hid import statements inside a function. They should all appear at the top of the file unless you are trying to get around a circular reference problem.

As I said before, you cannot judge design in a vacuum. If this design works well for solving your problem, it is a good design. I can say that is is not a generic solution. This would never be a module that others can use to solve their problem. Components should be generic. An inventory control system would never have a "refill_all_components" method. It might have method(s) to check inventory numbers and aid in ordering, but "get everything right now" is unrealistic. In an inventory system the components would be more than just a string, they would be objects. The inventory system would know how to communicate with objects to let you know if a component was available or when a component was available.

Is this a good design? Maybe yes. Maybe no.

Thanks that make sense. Anyway next time, I try to design something more generic and reusable. (On the other hand I guess that means more codeing)
Reply


Messages In This Thread
Class variable / instance variable - by ifigazsi - Jul-26-2020, 02:32 PM
RE: Class variable / instance variable - by buran - Jul-26-2020, 03:20 PM
RE: Class variable / instance variable - by Yoriz - Jul-26-2020, 04:03 PM
RE: Class variable / instance variable - by ifigazsi - Jul-27-2020, 09:03 PM
RE: Class variable / instance variable - by buran - Jul-28-2020, 11:40 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  is this a valid variable name? Skaperen 6 319 Yesterday, 10:13 PM
Last Post: Skaperen
  Help with writing monitored data to mysql upon change of one particular variable donottrackmymetadata 3 434 Apr-18-2024, 09:55 PM
Last Post: deanhystad
  Commas issue in variable ddahlman 6 626 Apr-05-2024, 03:45 PM
Last Post: deanhystad
  Variable Explorer in spyder driesdep 1 360 Apr-02-2024, 06:50 AM
Last Post: paul18fr
  Mediapipe. Not picking up second variable stevolution2024 1 334 Mar-31-2024, 05:56 PM
Last Post: stevolution2024
Question Variable not defined even though it is CoderMerv 3 446 Mar-28-2024, 02:13 PM
Last Post: Larz60+
  optimum chess endgame with D=3 pieces doesn't give an exact moves_to_mate variable max22 1 351 Mar-21-2024, 09:31 PM
Last Post: max22
  unbounded variable akbarza 3 617 Feb-07-2024, 03:51 PM
Last Post: deanhystad
  Variable for the value element in the index function?? Learner1 8 800 Jan-20-2024, 09:20 PM
Last Post: Learner1
  Variable definitions inside loop / could be better? gugarciap 2 548 Jan-09-2024, 11:11 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020