code-organization

Where do you like to put MVC view model data transformation logic?

梦想与她 提交于 2019-12-23 08:53:48
问题 Here is the scenario, I need to load up a view model object from a several domain objects that are being returned from multiple web service service calls. The code that transforms the domain model objects into the digestible view model object is a bit of fairly complex code. The three places that I have thought about putting it are: Internal methods inside of the controller to load up an instance view model. Static get method or property on the view model class itself that returns a loaded

Why does django enforce all model classes to be in models.py?

帅比萌擦擦* 提交于 2019-12-22 03:16:57
问题 I have just learned that splitting model classes into different files breaks many of django's built-in functionalities. I am coming from a java background. There, it is not accepted as a good practice writing very long class files. But django's enforcement of single file for all model classes will probably cause programmer to write very long models.py files. This will make it difficult for programmer to see the organization of the whole domain model. So why does django enforce single file to

C++ project source code layout

柔情痞子 提交于 2019-12-21 09:36:57
问题 One of the popular way to organize project directory is more or less like this: MyLib +--mylib_class_a.h mylib_class_a.cpp mylib_library_private_helpers.h mylib_library_private_helpers.cpp MyApp +--other_class.h other_class.cpp app.cpp app.cpp : #include "other_class.h" #include <mylib_class_a.h> // using library MyLib All .h and .cpp files for the same library are in the same directory. To avoid name collision, file names are often prefix with company name and/or library name. MyLib will be

Best way to organize the files in my project

◇◆丶佛笑我妖孽 提交于 2019-12-21 02:55:13
问题 What is the best way to organize the files in your project? For example do you put all user controls in a separate folder or do you place them in a sub folder? Do you have business logic folder? A helper classes folder? I used to organize my projects like this: Project/User Controls/Module Name/ Project/Classes/Module Name/ Now I am learning more towards something like this: Project/Module Name/User Controls/ Project/Module Name/Classes/ What is the best way? Especially if the project gets

Tips on organizing larger Android projects?

房东的猫 提交于 2019-12-20 10:26:31
问题 My current project is getting awfully large. I have dozens of activities, adapters, fragments, layout xmls, and other resources. In my (smaller) previous projects I organized stuff with a 1 package / 1 category style. So I had com.stuff.xy.adapter, com.stuff.xy.activity, and so on. Now these packages contain too many items, and I find myself wasting considerable amounts of time searching for a specific class in the package hierarchy. I use Eclipse, and there are some shortcuts one can use (go

How to code a simple versioning system?

大兔子大兔子 提交于 2019-12-20 08:39:50
问题 I want to do a simple versioning system but i don't have ideas on how to structure my datas, and my code. Here is a short example: User logs in User has two options when uploading a file: Submit a new file Submit a new version of a file Users should be able to see the tree. (the different version) The tree can only be up to 2 levels: | |--File_A_0 \--File_A_1 \--File_A_2 \--File_A_3 \--File_A_4 There are also 2 types of file, a final (which is the latest approved version) and a draft version

Is it bad style to use return at the beginning of a function to avoid doing unnecessary work? [closed]

狂风中的少年 提交于 2019-12-20 05:52:14
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Say we have a function foo(), and a bool bar. The work foo does is of no use if bar is false. What is the most proper way to write foo

Organizing Actions in a Swing Application?

懵懂的女人 提交于 2019-12-18 16:26:11
问题 My current application has a JFrame with about 15 actions stored as fields within the JFrame. Each of the actions is an anonymous class and some of them are pretty long. Is it common to break actions into their own classes possibly within a sub-package called actions? If not, how's this complexity usually tamed? Thanks 回答1: If it is possible that your actions could be reusable (e.g., from keyboard shortcuts, other menus, other dialogs, etc.) and especially if they can work directly on the

Should I put many functions into one file? Or, more or less, one function per file?

半城伤御伤魂 提交于 2019-12-18 15:17:37
问题 I love to organize my code, so ideally I want one class per file or, when I have non-member functions, one function per file. The reasons are: When I read the code I will always know in what file I should find a certain function or class. If it's one class or one non-member function per header file, then I won't include a whole mess when I include a header file. If I make a small change in a function then only that function will have to be recompiled. However, splitting everything up into

F# code organization: types & modules

限于喜欢 提交于 2019-12-18 10:42:53
问题 How do you decide between writing a function inside a module or as a static member of some type? For example, in the source code of F#, there are lots of types that are defined along with a equally named module, as follows: type MyType = // ... [<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] module MyType = // ... Why don't you simply define the operations as static members of type MyType? 回答1: Here are some notes about the technical distinctions. Modules can be