python - Returning an object vs returning a tuple -
I am developing a file class in Python which can read and write a file, which contains a list of xyz coordinates In my program, I already have a Coord3D class to keep xyz coordinates.
My question is relative to the design of getCoordinate (Index) method, should I return the float's Tupal or Coord3D object?
In the first case, I get very little coupling, but then I have to instantiate the Coord3D object with any available values, though in the second case of the outside file class, Will be kept tightly together with 3D class.
Please note that I think there are no major differences in the two solutions, but I want to read your answer the reason behind it.
Edit : Repeat the answers I have so far, it seems that there is no obvious choice. It has been said (proper) that the dragon is not Java, and you do not need any special classes for all because you need it by language structure. In my case, however, I have the following conditions:
- I am working on a library where Coord 3D is used as an object. By using it, my library coordinates Will increase, because the data types will be used equally.
- Coord3D objects have state and behavior Actually, Coord3D objects coordinate and collect units in one unit. Between Coord3D objects, operations will take into account potentially different units, and will act accordingly.
- I can put in the convergent 3D class instantaneity to deny the control code, for example, arrays of length 4, or non-units if I use Tupal, I do not check this can. In addition, if any method accepts Coord3D, then it is definitely guaranteed that it is well-formed upfront (you can be bold and check the intensification, or check the interface). A tube may contain invalid data, though the dragon approach is used to handle the error, where the problem occurs, a class prevents me from keeping xyz co-ordinate with three strings, somehow beneficial (if incorrect then I Correct)
On the other hand, there are advantages to using Tupal:
- Less business resources, significant in terms of vast
- Simple D Zine more classes means more intricate designs. A tube is a standard data type that is well understood and can be easily unexpected. There is no personalized class.
- Using Tuplix, the XYZFile class is fully decomposed from the rest of the library (since it does not use the Coord3D object) it means that it is independently an independent unit Can be reused as.
Further comments are very welcome!
I have asked myself the same question, although while doing 2D geometry stuff.
I had given the answer to myself that if I was planning to write a larger library, more work and whatnot, go ahead and point back, or in your case Coord3D object if it is just a hackney implementation If so, Tupal will move you faster. Finally, what you are doing with it, and it's worth the effort.
Comments
Post a Comment