code-organization

Implementing interfaces in partial classes

China☆狼群 提交于 2019-12-10 02:04:23
问题 Consider a class which implements a lot of interfaces, would it make sense to implement each interface in a separate file using partial class definitions? Would this be an abuse of the language feature or is it an idiom I'm unaware of? 回答1: If your class has to implement many interfaces, that's a reasonable way of managing the source, yes. You can edit the project file to make several of them depend on one "main" class file, which makes the Solution Explorer easier to work with. You should

Is it safe to indent with 2 spaces?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 01:33:57
问题 I know the general answer to "How should I indent my code" is generally "do as you wish but do it the same way as everyone on your team", but in the last time I've seen many projects and platforms relying on a 2-space indentation . I just want to make sure I get the "best bang for my buck" when indenting and make sure it's future-proof. Changing the structure in a project later on is a pretty big problem considering compatibility, etc. Most projects now rely on 2 Spaces , 4 Spaces or Tabs .

How to organise large code files?

拟墨画扇 提交于 2019-12-09 04:52:03
问题 I am increasingly aware that my code in any single file can often span hundreds of lines quite easily and although I know the implementation might be sound, it still feels messy and unorganised. I understand that there are situations where a lot of code is neccessary, but whats the best way to organise it all? I've thought about separating variables from methods, private s from public s and internals but I don't want to because I can't help thinking that the components of ONE class belong in

Avoiding virtual functions

梦想与她 提交于 2019-12-09 03:36:13
问题 So suppose I want to make a series of classes that each have a member-function with the same thing. Let's call the function void doYourJob(); I want to eventually put all these classes into the same container so that I can loop through them and have each perform 'doYourJob()' The obvious solution is to make an abstract class with the function virtual void doYourJob(); but I'm hesitant to do so. This is a time-expensive program and a virtual function would slime it up considerably. Also, this

Mercurial: Granular Repositories Vs large Repositories and shared third party tools in version control

只愿长相守 提交于 2019-12-08 19:36:09
问题 This question was migrated from Software Engineering Stack Exchange because it can be answered on Stack Overflow. Migrated 8 years ago . Scenario: Various products made up combinations of the smaller projects. A few different versions of each product in dev, release and maintennace (bugs/patches/minor releases). Most the the team use various third party tools and libraries for dev and for release (common two are XUnit for dev, and AutoMapper in product). They're fans of version controlling

Do modern C++ compilers inline functions which are called exactly once?

做~自己de王妃 提交于 2019-12-08 15:51:33
问题 As in, say my header file is: class A { void Complicated(); } And my source file void A::Complicated() { ...really long function... } Can I split the source file into void DoInitialStuff(pass necessary vars by ref or value) { ... } void HandleCaseA(pass necessary vars by ref or value) { ... } void HandleCaseB(pass necessary vars by ref or value) { ... } void FinishUp(pass necessary vars by ref or value) { ... } void A::Complicated() { ... DoInitialStuff(...); switch ... HandleCaseA(...)

Organize small utilities functions

人走茶凉 提交于 2019-12-08 07:51:34
问题 After years of programming, we all have a set of small functions used as helpers utilities that we wish it comes build-in so we can use it in any project and have ti taken care by more people (test and optimized). I have quite a collection of these functions. I wonder how do you guys organize them? Do you have any tips? This is how I do it. I put it in a separate project (an eclipse project) let say "MyUtils" and it referred to by other projects. This works but because the utils collection

Only one or many functions per file in PHP?

我只是一个虾纸丫 提交于 2019-12-08 03:38:17
问题 I have this problem that is really causing me headeches whenever i'm designing my apps in php: I don't know if i should create separete files for each function(e.g.: functions for validating specific forms). OK, one would possibily argue that this makes no sense because I would have to include each file separetly and this would result in a more slow application maybe? But I still think it does make sense since for one pageload i doubt that other functions would be used by the script at all,

How to organize Data Access Layer (DAL) in ASP.NET

百般思念 提交于 2019-12-07 07:47:34
问题 I have an ASP.NET Web Forms application developed in C#. I would like to give structure my application by separating the DAL tasks from the code behind. I created a class in App_Code, DBUtilities that takes care of the communication with the database, in order not to have duplicated code all along the application. The class has methods to get datatables, scalar values, etc... and they accept as parameters the connection string name and the query command as string. The problem is that I have

Wrapping an Unmanaged C++ Class Library with C++/CLI - Question 1 - Project/Code Organization

最后都变了- 提交于 2019-12-06 20:54:07
问题 Note: This post represents Question #1 of my inquiry. The introduction block (all text until the numbers are reached) is repeated in both questions as it is background information that may be needed to answer the question. Introduction to Question I have an unmanaged C++ library that contains classes and functions that are common to and shared among several "higher level" libraries. I now have need to provide access to the common library to C#/.Net applications. To do this, I will have to