问:
Are code reviews necessary for junior developers?
I've worked at two companies, who each had a different methodology when it came to code reviews:

In the first company, a code review was conducted by the team leaders and was required after the completion of every module.

However, in the second company, team leaders weren't required to conduct any code reviews, and just checked for functionality and design issues.

So I am confused. Is the code review process really needed? If it is, why? And if it isn't, why not?

答:
Code reviews can identify defects earlier in the software lifecycle when issues are easier (and cheaper) to fix. At SmartBear we have developed a peer code review tool and have also done a lot of research into how to make code reviews effective. Based on data from our customers, defects found in code review are 8-12X cheaper to find and fix than defects found in QA. The cost savings alone makes code review worth it, but there is more value than just that. Code review is an excellent way for everyone on the team to learn and improve as software developers.

There are some traps that can cause code reviews to become less effective, and it seems like your organization is caught in one of them. Make the code review about the code, not the people. Titles mean nothing in a code review. Appeals to authority (you must do it my way because I'm the team lead) do more harm than good. Teach instead. Senior engineers should explain why it should be done their way, not just demand that it is. If you're having a hard time explaining a concept, it's a learning experience for you too. Both of you will be better developers for the effort you put in.


问:
Never use Strings in Java?
I stumbled upon a blog entry discouraging the use of Strings in Java for making your code lack semantics, suggesting that you should use thin wrapper classes instead. This is the before and after examples the said entry provides to illustrate the matter:

```<code>public void bookTicket(
  String name,
  String firstName,
  String film,
  int count,
  String cinema);

public void bookTicket(
  Name name,
  FirstName firstName,
  Film film,
  Count count,
  Cinema cinema);
</code>```

In my experience reading programming blogs I've come to the conclusion that 90% is nonsense, but I'm left wondering whether this is a valid point. Somehow it doesn't feel right to me, but I couldn't exactly pinpoint what is amiss with the style of programming.

答: To bring an example: in our currently developed system, there are lots of different entities which can be identified by multiple kinds of identifiers (due to the usage of external systems), sometimes even the same kind of entity. All of the identifiers are Strings - so if someone mixes up which kind of id should be passed as parameter, no compile time error is shown, but the program will blow up at runtime. This happens quite often. So I have to say that this principle's primary purpose is not to protect against change (although it serves that also), but to protect ourselves from bugs. And anyway, if someone designs an API, it has to reflect the concepts of the domain, so it is conceptually useful to define domain-specific classes - everything depends on whether there is order in the mind of the developers, and this can be greatly facilitated by the type system!</p>

ContentLicense: CC BY-SA 3.0

Title: Never use Strings in Java?


问:
Validation and authorization in layered architecture
I know you are thinking (or maybe yelling), "not another question asking where validation belongs in a layered architecture?!?"  Well, yes, but hopefully this will be a little bit of a different take on the subject.

I am a firm believer that validation takes many forms, is context-based and varies at each level of the architecture.  That is the basis for the post - helping to identify what type of validation should be performed in each layer.  In addition, a question that often comes up is where authorization checks belong.

The example scenario comes from an application for a catering business. Periodically during the day, a driver may turn in to the office any excess cash they've accumulated while taking the truck from site to site.  The application allows a user to record the 'cash drop' by collecting the driver's ID, and the amount.  Here's some skeleton code to illustrate the layers involved:

```<code>public class CashDropApi  // This is in the Service Facade Layer
{
    [WebInvoke(Method = "POST")]
    public void AddCashDrop(NewCashDropContract contract)
    {
        // 1
        Service.AddCashDrop(contract.Amount, contract.DriverId);
    }
}

public class CashDropService  // This is the Application Service in the Domain Layer
{
    public void AddCashDrop(Decimal amount, Int32 driverId)
    {
        // 2
        CommandBus.Send(new AddCashDropCommand(amount, driverId));
    }
}

internal class AddCashDropCommand  // This is a command object in Domain Layer
{
    public AddCashDropCommand(Decimal amount, Int32 driverId)
    {
        // 3
        Amount = amount;
        DriverId = driverId;
    }

    public Decimal Amount { get; private set; }
    public Int32 DriverId { get; private set; }
}

internal class AddCashDropCommandHandler : IHandle<AddCashDropCommand>
{
    internal ICashDropFactory Factory { get; set; }       // Set by IoC container
    internal ICashDropRepository CashDrops { get; set; }  // Set by IoC container
    internal IEmployeeRepository Employees { get; set; }  // Set by IoC container

    public void Handle(AddCashDropCommand command)
    {
        // 4
        var driver = Employees.GetById(command.DriverId);
        // 5
        var authorizedBy = CurrentUser as Employee;
        // 6
        var cashDrop = Factory.CreateCashDrop(command.Amount, driver, authorizedBy);
        // 7
        CashDrops.Add(cashDrop);
    }
}

public class CashDropFactory
{
    public CashDrop CreateCashDrop(Decimal amount, Employee driver, Employee authorizedBy)
    {
        // 8
        return new CashDrop(amount, driver, authorizedBy, DateTime.Now);
    }
}

public class CashDrop  // The domain object (entity)
{
    public CashDrop(Decimal amount, Employee driver, Employee authorizedBy, DateTime at)
    {
        // 9
        ...
    }
}

public class CashDropRepository // The implementation is in the Data Access Layer
{
    public void Add(CashDrop item)
    {
        // 10
        ...
    }
}
</code>```

I've indicated 10 locations where I've seen validation checks placed in code.  My question is what checks you would, if any, be performing at each given the following business rules (along with standard checks for length, range, format, type, etc):

The amount of the cash drop must be greater than zero.

The cash drop must have a valid Driver.

The current user must be authorized to add cash drops (current user is not the driver).

Please share your thoughts, how you have or would approach this scenario and the reasons for your choices.

答:
I agree that what you are validating will be different in each layer of the application.  I typically only validate what is required to execute the code in the current method.  I try to treat the underlying components as black boxes and don't validate based on how those components are implemented.

So, as an example, in your CashDropApi class, I would only verify that 'contract' is not null.  This prevents NullReferenceExceptions and is all that is needed to ensure this method executes properly.

I don't know that I'd validate anything in the service or command classes and the handler would only verify that 'command' is not null for the same reasons as in the CashDropApi class.  I've seen (and done) validation both ways wrt to the factory and entity classes. One or the other is where you'd want to validate the value of 'amount' and that the other parameters are not null (your business rules).

The repository should only validate that the data contained in the object is consistent with the schema defined in your database and the daa operation will succeed. For example, if you have a column that can't be null or has a max length, etc.

As for the security check, I think it is really a question of intent.  Since the rule is intended to prevent unauthorized access, I would want to make this check as early in the process as possible to reduce the number of unnecessary steps I've taken if the user is not authorized.  I'd probably put it in the CashDropApi.


问:
Layers - Logical seperation vs physical
Some programmers recommend logical seperation of layers over physical.  For example, given a DL, this means we create a DL namespace not a DL assembly.

Benefits include:

faster compilation time

simpler deployment

Faster startup time for your program

Less assemblies to reference

Im on a small team of 5 devs.  We have over 50 assemblies to maintain.  IMO this ratio is far from ideal.  I prefer an extreme programming approach.  Where if 100 assemblies are easier to maintain than 10,000...then 1 assembly must be easier than 100.  Given technical limits, we should strive for < 5 assemblies.  New assemblies are created out of technical need not layer requirements.

Developers are worried for a few reasons.

A.  People like to work in their own environment so they dont step on eachothers toes.

B.  Microsoft tends to create new assemblies.  E.G. Asp.net has its own DLL, so does winforms.  Etc.

C.  Devs view this drive for a common assembly as a threat.  Some team members Have a tendency to change the common layer without regard for how it will impact dependencies.

My personal view:

I view A. as silos, aka cowboy programming and suggest we implement branching to create isolation.  C. First, that is a human problem and we shouldnt create technical work arounds for human behavior. Second, my goal is not to put everything in common.  Rather, I want partitions to be made in namespaces not assemblies.  Having a shared assembly doesnt make everything common.

I want the community to chime in and tell me if Ive gone off my rocker.  Is a drive for a single assembly or my viewpoint illogical or otherwise a bad idea?

答:
In principle, I support your desire for fewer assemblies. Having multiple assemblies needs technical justification, while having few assemblies has simpleness on its side and needs no other justification.

In general, logical separation is stronger and cleaner than physical separation. The boundary between assemblies is a very small technical hindrance for bug and code rot. The most powerful boundary is the social boundary ("that's Tom's library, I won't fuck around in there"), and namespaces provide the same safety.

Be aware, though, that there are technical reasons for separate assemblies, even though all good of them are on the deployment and consumer site.

Title: Layers - Logical seperation vs physical


问:
Stored Procedures a bad practice at one of worlds largest IT software consulting firms?
I'm working at a project in one of the world's top 3 IT consulting firms, and was told by a DBA that company best practice's state stored procedures are not a "best practice".  This is so contrary to everything I've learned.

Stored procedures give you code reuse, and encapsulation (two pillars of software development), security (you can grant/revoke permissions on an individual stored proc), protect you from SQL injection attacks, and also help with speed (although that DBA said that starting with SQL Server 2008 that even regular SQL queries are compiled if they are run enough times).

We're developing a complex app using Agile software development methodology.  Can anyone think of good reasons why they wouldn't want to use stored procs?  My guess was that the DBAs didn't want to maintain those stored procs, but there seem to be way too many negatives to justify such a design decision.

答:
I agree with Mark that the community has really been moving away from stored procedures for quite some time now.  While many of the points the original poster raised why we may want to use SPs were valid at one time, it has been quite a while and, as another poster said, the environment has changed.  For instance, I remember one argument FOR using SPs 'back in the day' was the performance gains achieved because their execution plans were 'pre-compiled' while dynamic SQL from our code had to be 're-compiled' with each execution.  This is no longer the case as the major databases have changed, improved, adapted, etc.

That said, we are using SPs on my current project.  The reason is simply because we are building new applications on top of an existing database that still supports legacy applications. As a result, making schema changes is very difficult until we turn off the legacy apps.  We made a conscious decision to design our new applications based on the behavior and rules required for the application and to use the SPs to temporarily interface with the database the way we'd like it to be and allow the SPs to adapt to the existing SQL.  This goes to a previous poster's point that SPs make it easier to make changes at the database level without requiring changes to the application code.  Using SPs as an implementation of the Adapter pattern certainly makes sense to me (esp. given my current project), and may be the only argument I can really see FOR their use today.

Fwiw, it is our intention to remove the SPs when the schema is updated.  But, as with everything else in corporate development, we'll see if that ever happens! [grin]


问:
How to get new team members up to date with the project?
We are about to hire 1-2 new engineers for the software team (consisting of 3 developers, 1 tester).

What are the steps to integrate them into the team?

My ideas are :

read documentation (coding standards, documents in development methodologies we use)

get them to read the existing code

assign them some simple tasks

at the end, make them responsible for the code part

What else could we do?

The project is in a medical sector (ultrasound system), and is already 5 years going. We have yearly releases, and we are about to finish one release, when we want to add 1-2 engineers.

The project is in the maintenance phase (refactoring legacy code, plus adding new features). Things are pretty much on schedule (more or less).

答:
Coming from someone who has had to come up to speed on a lot of different codebases in my career, here's what I would suggest:

Spend a short amount of time (maybe a day or two) with activities related to using the product so that they can become familiar with what the product does.  This could be verifying bugs or executing QA test plans or going through user training.

Work on small, localized bugs.  This gets the engineer familiar with how to build & debug the application without having to deal with learning a lot of the architecture.

Ideally, write a small new feature that's localized.  This lets them write a chunk of code and as they write it they will become familiar with the surrounding bits of code that their new code needs to work with.

From there, expand the scope and complexity of assignments over time depending on the engineer's experience level and aptitude.  That will let the developer expand their knowledge of the codebase naturally.

I would avoid reading only tasks (documentation or code).  Reading documentation gets really boring really fast and reading random code isn't helpful since they won't have any context to work with.  It's hard enough to read code for code reviews when you already know the product & codebase.  I can't see anything useful coming out of having a brand new engineer just reading the code.


答:
Here is really good guide for what reasons you should split .NET programs into assemblies, and for what reasons you should not do this. Related to your question, the paper says that A should be handled by your SCCS, the rationale behind B may be visibility reasons you don't have to care for as long as you are not a framework vendor, and C may be handled by a tool like NDepend.

Of course, this is recommended by the manufacturers of NDepend, which is a commercial tool, and checking for cyclic dependencies between different logical layers in one assembly is only feasible with a tool like NDepend. So what they suggest makes mostly sense if you buy their tool (nevertheless most of the arguments in the document seem reasonable to me).

Title: Layers - Logical seperation vs physical

Body:
Some programmers recommend logical seperation of layers over physical.  For example, given a DL, this means we create a DL namespace not a DL assembly.

Benefits include:

faster compilation time

simpler deployment

Faster startup time for your program

Less assemblies to reference

Im on a small team of 5 devs.  We have over 50 assemblies to maintain.  IMO this ratio is far from ideal.  I prefer an extreme programming approach.  Where if 100 assemblies are easier to maintain than 10,000...then 1 assembly must be easier than 100.  Given technical limits, we should strive for < 5 assemblies.  New assemblies are created out of technical need not layer requirements.

Developers are worried for a few reasons.

A.  People like to work in their own environment so they dont step on eachothers toes.

B.  Microsoft tends to create new assemblies.  E.G. Asp.net has its own DLL, so does winforms.  Etc.

C.  Devs view this drive for a common assembly as a threat.  Some team members Have a tendency to change the common layer without regard for how it will impact dependencies.

My personal view:

I view A. as silos, aka cowboy programming and suggest we implement branching to create isolation.  C. First, that is a human problem and we shouldnt create technical work arounds for human behavior. Second, my goal is not to put everything in common.  Rather, I want partitions to be made in namespaces not assemblies.  Having a shared assembly doesnt make everything common.

I want the community to chime in and tell me if Ive gone off my rocker.  Is a drive for a single assembly or my viewpoint illogical or otherwise a bad idea?


答:
These were my formula and used with several new comers - these steps proven to be highly effective.

a) All new developers will be given some introduction about the project requirements and development processes for 2 days.

b) Assigning 3 weeks task of writing Junit tests for the code which does not have enough coverage.

c) Once 3 is done,  assign small tasks

d) Assign complex tasks and done.

Title: How to get new team members up to date with the project?

Body:
We are about to hire 1-2 new engineers for the software team (consisting of 3 developers, 1 tester).

What are the steps to integrate them into the team?

My ideas are :

read documentation (coding standards, documents in development methodologies we use)

get them to read the existing code

assign them some simple tasks

at the end, make them responsible for the code part

What else could we do?

The project is in a medical sector (ultrasound system), and is already 5 years going. We have yearly releases, and we are about to finish one release, when we want to add 1-2 engineers.

The project is in the maintenance phase (refactoring legacy code, plus adding new features). Things are pretty much on schedule (more or less).


问:
Is it a good practice to use smaller data types for variables to save memory?
When I learned the C++ language for the first time I learned that besides int, float etc, smaller or bigger versions of these data types existed within the language. For example I could call a variable x

```<code>int x;
or
short int x;
</code>```

The main difference being that short int takes 2 bytes of memory while int takes 4 bytes, and short int has a lesser value, but we could also call this to make it even smaller:

```<code>int x;
short int x;
unsigned short int x;
</code>```

which is even more restrictive.

My question here is if it's a good practice to use separate data types according to what values your variable take within the program. Is it a good idea to always declare variables according to these data types?

答:
The answer depends on your system. Generally, here are the advantages and disadvantages of using smaller types:

Advantages

Smaller types use less memory on most systems.

Smaller types gives faster calculations on some systems. Particularly true for float vs double on many systems. And smaller int types also give significantly faster code on 8- or 16-bit CPUs.

Disadvantages

Many CPUs have alignment requirements. Some access aligned data faster than unaligned. Some must have the data aligned to even be able to access it. The larger integer types equal one aligned unit, so they are most likely not misaligned. This means that the compiler might be forced to put your smaller integers in larger ones. And if the smaller types are part of a larger struct, you may get various padding bytes silently inserted anywhere in the struct by the compiler, to fix alignment.

Dangerous implicit conversions. C and C++ have several obscure, dangerous rules for how variables are promoted to larger ones, implicitly without a typecast. There are two sets of implicit conversion rules entwined with each other, called the "integer promotion rules" and the "usual arithmetic conversions." Read more about them here. These rules are one of the most common causes for bugs in C and C++. You can avoid a whole lot of problems by simply using the same integer type all over the program.

My advise is to like this:

```<code>system                             int types

small/low level embedded system    stdint.h with smaller types
32-bit embedded system             stdint.h, stick to int32_t and uint32_t.
32-bit desktop system              Only use (unsigned) int and long long.
64-bit system                      Only use (unsigned) int and long long.
</code>```

Alternatively, you can use the int_leastn_t or int_fastn_t from stdint.h, where the n is the number 8, 16, 32 or 64. int_leastn_t type means "I want this to be at least n bytes but I don't care if the compiler allocates it as a larger type to suit alignment".

int_fastn_t means "I want this to be n bytes long, but if it will make my code will run faster, the compiler should use a larger type than specified".

Generally, the various stdint.h types are much better practice than plain int etc, because they are portable. The intention with int was to not give it a specified width solely to make it portable. But in reality, it is hard to port because you never know how large it will be on a specific system.

Body:
The answer depends on your system. Generally, here are the advantages and disadvantages of using smaller types:

Advantages

Smaller types use less memory on most systems.

Smaller types gives faster calculations on some systems. Particularly true for float vs double on many systems. And smaller int types also give significantly faster code on 8- or 16-bit CPUs.

Disadvantages

Many CPUs have alignment requirements. Some access aligned data faster than unaligned. Some must have the data aligned to even be able to access it. The larger integer types equal one aligned unit, so they are most likely not misaligned. This means that the compiler might be forced to put your smaller integers in larger ones. And if the smaller types are part of a larger struct, you may get various padding bytes silently inserted anywhere in the struct by the compiler, to fix alignment.

Dangerous implicit conversions. C and C++ have several obscure, dangerous rules for how variables are promoted to larger ones, implicitly without a typecast. There are two sets of implicit conversion rules entwined with each other, called the "integer promotion rules" and the "usual arithmetic conversions." Read more about them here. These rules are one of the most common causes for bugs in C and C++. You can avoid a whole lot of problems by simply using the same integer type all over the program.

My advise is to like this:

system                             int types

small/low level embedded system    stdint.h with smaller types
32-bit embedded system             stdint.h, stick to int32_t and uint32_t.
32-bit desktop system              Only use (unsigned) int and long long.
64-bit system                      Only use (unsigned) int and long long.

Alternatively, you can use the int_leastn_t or int_fastn_t from stdint.h, where the n is the number 8, 16, 32 or 64. int_leastn_t type means "I want this to be at least n bytes but I don't care if the compiler allocates it as a larger type to suit alignment".

int_fastn_t means "I want this to be n bytes long, but if it will make my code will run faster, the compiler should use a larger type than specified".

Generally, the various stdint.h types are much better practice than plain int etc, because they are portable. The intention with int was to not give it a specified width solely to make it portable. But in reality, it is hard to port because you never know how large it will be on a specific system.


答:
1) Give them an explanation of your code rules and guidelines. Also give a general explanation of how your application works and the general code structure.

2) Find some small bugs or projects that are largely independent of other code. Explain what needs to be done, where in the code and check on them regularly.

3) Slowly start giving them larger and larger projects while checking them less and less.

4) Sit next to them from time to time. You can learn a lot by just looking how someone else tackles a problem. Small things like "oh, you can look for functions in your code by presing ctrl-." are very useful.

Now, I've found that there are two extremes:

Someone who asks a question every five minutes. "What does this Path.Join  do?". They should Google first for an answer and only come to you when they can't find an answer.

And the other extreme, someone who works for half a day without asking a single question. They should feel like it's a good thing to ask questions. I just want them to first try it out themselves.


问:
My coworker created a 96 columns SQL table
Here we are in 2010, software engineers with 4 or 5 years or experience, still designing tables with 96 fracking columns.

I told him it's gonna be a nightmare.

I showed him that we have to use ordinals to interface MySQL with C#.

I explained that tables with more columns than rows are a huge smell.

Still, I get the "It's going to be simpler this way".

What should I do?

EDIT *

This table contains data from sensors.

We have sensor 1 with

Dynamic_D1X

Dynamic_D1Y

[...]

Dynamic_D6X

Dynamic_D6Y

[...]

EDIT2 *

Well, I finally left that job. It is a sign when the other programmer goes dark for months at the time, it is another sign when management does not realise this is a problem

答:
Maybe he did that for a good reason, such as performances or ROI ?.

The best thing to do, is asking him questions. With a certain amount of "why" you will certainly make him understand he is probably wrong by itself (if he really is).

I had one case myself that is not related to performances but return on investment (ROI). I had a table containing objects that had a specific value for each hour of the week (168h in a week). We had the choice to create a ObjectHour table that would contain the value, but also a key to the Object and the day number of hour number. But we also had the opportunity to put the 168 values right in the row. Probably like what your coleague did.

The developers estimated both solutions. The simple solution (168 columns) was a lot cheaper to do than its well designed counterpart. For the exact same result for the customer.

We decided to go for the simple/cheapest solution to focus our efforts of more important stuffs such as security.

We will have many opportunities to improve that in the future. Time to market was the priority for us at the time.

ContentLicense: CC BY-SA 2.5


问:
Which revision control system to use for 2 semester capstone course?
For CS undergraduate students working on a 2-semester capstone course without any prior exposure to revision control systems, what would be a good one to use?

Desirable qualities would be easy to use (ie this should be a tool they can use rather than spend a lot of time fighting it) and still be relevant for subsequent professional work once they graduate (doesn't have to mean it has to be the same tool later on as long as the concepts survive).

Easy to install and maintain for the person who does this. Not sure if I am missing anything else important.

I am aware of subversion (centralized), git (distributed) and mercurial(also distributed?) - but don't know enough about any of them to have an informed opinion. Are there others I should consider? This will be on a predominantly Windows environment.

EDIT: I am really interested in the  pedagocial aspect of teaching/learning these systems, not so much from the perspective of an already experienced software developer.

答:
Git is probably the best one.

There is the Git-Client SmartGit (and similar ones) for newcomers. Git is very popular and there is github, where students can store the files. (At my university all courses use git. In most cases the repositories are public hosted on github.)


答:
Git: most powerful, steepest learning curve. Support under Windows was not stellar last time I checked. Unless the students are already familiar with it, think twice. Extremely popular so it might be worth teaching nevertheless.

Mercurial: easier than git, but still distributed with all the advantages of this (cheap branching, work offline). Should take less effort teaching. Supported well under Windows.

Subversion: centralized, conceptually the simplest of the three, but not significantly. Supported well under Windows. Needs the students to be always connected to the server to reap the benefits of version control. Used to be least friendly of all when merging.

I'd take Mercurial.

Title: Which revision control system to use for 2 semester capstone course?

Body:
For CS undergraduate students working on a 2-semester capstone course without any prior exposure to revision control systems, what would be a good one to use?

Desirable qualities would be easy to use (ie this should be a tool they can use rather than spend a lot of time fighting it) and still be relevant for subsequent professional work once they graduate (doesn't have to mean it has to be the same tool later on as long as the concepts survive).

Easy to install and maintain for the person who does this. Not sure if I am missing anything else important.

I am aware of subversion (centralized), git (distributed) and mercurial(also distributed?) - but don't know enough about any of them to have an informed opinion. Are there others I should consider? This will be on a predominantly Windows environment.

EDIT: I am really interested in the  pedagocial aspect of teaching/learning these systems, not so much from the perspective of an already experienced software developer.


答:
In a project's infancy, it makes sense to separate modules into distinct assemblies because there will be a lot of flux and because of Visual Studio's project format, adding new files changes the project file in a way that makes merging difficult sometimes. Compare to rake or nant where you use wildcards to determine which files to include in the compilation.

For this reason, I prefer to start with separate physical assemblies and merge them together as the modules become more stable. Thus you get the best of both worlds...lower merge collisions at the start and better compilation/initial startup as you march toward release.

Title: Layers - Logical seperation vs physical


问:
Years experience over unfinished degree?
I'm currently in my placement year and working for a great software development company. It was always my intention of getting to this stage through university, getting enough academic experience as well as the year’s placement and then try to get a full time programming job without the need to finish my degree. I decided this from an early stage as I have never really liked the whole university environment. I was so unhappy at university and I’m so happy now I’m on my placement year, I really don’t know if I can go back.

My question is, do you think companies will take me on if I apply for other jobs after my placement year and not penalize me for not finishing my degree?

I guess at the end of the day I don't want to look back on my life and think "god, why didn't I just spend one more year being unhappy to have a job I love" but I know that even if I get a degree I could still end up without a programming job and this worries me more than anything.

答:
I would agree with what many have said above me and I would say that you should 100% go back and finish your degree in order to get the best full time position possible. Although your skills may be up to par, companies really look for the degree on the candidate in order to know they are qualified and although the college scene was not for you, there are plenty of online options out there that could be a good fit. In terms of money I think you will see a major increase with a degree than you would without. Like I said earlier there are plenty of options of online education that might be a better fit for you than a stand in class or big time university setting. I know mostly all accounting firms and financial firms that will only hire people that carry a degree with them and they are very excited about students that complete them online. Check out http://accountingcertificateprograms.net/ as well for more information that might help you find a program online that could fit what you are looking for.

Its a well known fact that right now the financial industry is doing very well and they can always use top notch programmers. I would check out http://www.bls.gov/ooh/Business-and-Financial/Accountants-and-auditors.htm as well in order to learn about what kind of opportunities you can get with your degree rather than trying to pursue jobs with out one.

Just personal opinion, but I think you are on the right track to find a good job you like but in terms of getting a degree I feel its a must in today's professional world and it will only help you find the best job that fits what your looking for.

best of luck!


答:
I wish git or mercurial were around when I was in college.  I think we used cvs for our big group project, and it was difficult getting the entire team to use it.  Part of the problem is college students often have a laptop as their only computer, with spotty internet service that often firewalls any non-http traffic.  Either that, or they use school computer labs with the same firewall issues, and that rarely have a source control client installed.  Even if you personally are better equipped than that, you have to think about the lowest common denominator on your team.

With distributed version control, you can put the client and a repo on a laptop or usb drive and work completely disconnected most of the time, with lots of different ways to share your changes:  sites like github, emailing bundles back and forth, or even just pushing and pulling from each other's thumb drives or laptops on a LAN when you get together for team meetings.

I might throw bzr into the ring.  It's more noob friendly than either mercurial or git, but also not as flexible.  Git has a reputation of being difficult for noobs.  The bare essentials are as easy to learn as any other VCS, but people get overwhelmed by all the different advanced options available, and aren't sure what's safe to ignore or not.  Its CLI syntax is also very unix-like, which makes it feel very intuitive for *nix users but a little quirky to others.  Mercurial's a good balance.  It hides a lot of the complexity, but is still very capable, with a syntax more familiar to Windows users.


答:
In the .NET ecosystem the existence of many assemblies is due to the belief that a cs/vb/fsproj file == assembly. Throw on top of that the practices MS has been pushing for years of having one cs/vb/fsproj for every 'layer' (I use that in quotes because they have pushed both layers and tiers at different times) and you end up with solutions that have dozens and even hundreds of project files, and ultimately assemblies, in them.

I'm a firm believer that Visual Studio, or any IDE, is not the place that you should be architecting the assembly output of your project. Call it Separation of Concerns if you will; I believe that writing code and assembling code are two different concerns. That leads me to the point where the projects/solutions that I see in my IDE should be organized and structured so as to best enable the development team to write code. My build script is the location where the architecture/development team(s) focus on how we are going to assemble the raw code into compiled artifacts and, ultimately, how we're going to deploy those to different physical locations. It's prudent to note that I absolutely do not use MSBuild and it's tight coupling to *proj file structures for my build scripts. MSBuild, and it's inherently tight coupling to the *proj files and their structures, doesn't allow us any flexibility in moving away from the problem of large project and assembly counts in our codebases. Instead I use other tools and feed the files needed directly to the compiler (csc.exe, vbc.exe, etc).

By taking this stand I'm able to have my development team focus on writing functionality without any thought to the assemblies that will be output. Someone, surely, will say "But that means that developers can put code into assemblies that it shouldn't be in." Just because the code would compile in the IDE doesn't mean that it would when running the build script...and ultimately, the build script is the one source of truth for how assemblies will be constructed. The thing is, to do this you'd probably have to alter the build script to pull that code into the unwanted location. A technique that I use to back this up is to create unit tests that both describe and verify the architecture and deployables on the project. If the classes in the UI layers should never reference those in the data access layer, then I write a test that enforces that. Those types of tests will need to be changed if we decide to change the deployables or architecture, but since they're also doubling as documentation on those topics we should be changing them to ensure that the documentation is up to date.

On the flip side of that argument is the fact that changing the assemblies and deployables becomes much easier and faster. Instead of having to move code and files from one *proj file to another, and incurring all the problems that many version control systems have with that task, all you have to do is rework the build script to source each assembly's content from the already existing physical locations. It's this capability that highlights the decoupling between how we structure our solution and *proj files and how we create our output assemblies. With this technique, we are able to adjust both the number and the contents of the assemblies that we create without ever having to adjust how the code is structured in the IDE. Not only do we have the flexibility to change our outputs regularly and easily, but when we do that the developers are not impacted by having to discover where files have moved to. The re-learning overhead of the changes is non-existent.

The one drawback that many people struggle with when looking at this type of solution is that you may no longer be able to just "Hit F5" to run the application. While I'd argue that you don't want to do that anyways, it has to be addressed. The solutions are available and they differ depending on the type of application that you're building. The one root similarity between them is that if you absolutely must step through the code to debug/test it, learn how to Attach To Process.

To summarize, use the IDE for developing code. Use a build scripting solution that is not reliant on the defined solution and *proj structures to design and create the deployables that the application needs. Keep those two tasks separate and you'll see a lot less friction due to deployment level changes.

Title: Layers - Logical seperation vs physical


问:
Scrum, DDD, and front-end development in an enterprise environment
So, I've been working for a bank for the past 4 years. My main responsibility has been online banking. Over the past year, we've been implementing the scrum methodology. We've also changed to domain driven design.

Now, my problem is regarding what management is planning on doing. They want to split the online banking team between the domain teams, so one developer from the online banking team will go into each domain team and work on online banking projects that are part of the domains. For example, if software development gets a project to create a new loan overview in the online bank, the loan team will handle it all the way from from database to UI.

My problem with this is that there is no focus on the online bank as a product anymore. There is no way to veto any new feature. The product owners in the domains can just dump any obscure new feature into the online bank that they want to. There is also no work happening to revamp core features that our users use all the time. Every project is to make something new and once it's release, developers have to start working on a new project immediately. There is no teamwork, each web developer has to work on a separate UI for a separate domain. No hardening.

Our suggestion to management is that the online banking team be it's own scrum team focusing on the online bank as a product. That team would have it's own scrum master and the online bank would have a product owner. That product owner would coordinate with the product owners of the domains and prioritize projects that have to happen in the online banks. If a project from one domain has higher priority than a project from another domain, he would explain to the domain PO that we have to work on the higher priority one first.

Management hasn't listened to us.

My question is, what is the right way to do this?

答:
The approach you describe is what is commonly termed a Scrum of Scrums...except there doesn't appear to be collaboration between the teams in terms of integration. Without that, you do risk having a hodgepodge of features without any consistency between them. The transition might be noticeable and jarring to the users as they go from say managing their mortgage to checking their savings balance. Basically, you'll end up with a series of Silos with few of the benefits of either approach (Scrum or DDD).

That being said, it's tough to judge from a few paragraphs what counterbalances have been put in place to avoid this scenario. For example, if the Product Owners do regularly meet and collaborate on features and approach then hopefully, they will address the system as a unified whole and the separation of teams is really just for simplification from a management perspective.

I'd say, give it a chance you might find that they know more than they're letting on at first ;)


答:
I would go from high level to low.

Demo the app as soon as possible

One of the most important things is that the developer has an idea what they will work on. During the demo, point out some of the things that have been under recent development, and the direction the app is going.

Explain the high level architecture

This is also very important. Allow the new dev to listen and ask questions. Do this as a group exercise with the other devs, who will hopefully chime in and help you out. This will let the new developer know that it is OK to speak up openly and honestly.

Have a great on-boarding document ready

Having a great on-boarding document does not only help new devs, but old ones as well. It can contain expectations, useful links and environment setup information. (I cannot tell you how many times I used our on-boarding to set up my environment when I get a new computer...) This should be well structured and to the point and not linger on and not be a dumping ground for every little detail.

Encourage him/her to ask questions (and be available to answer them)

With the answers, guide them, but do not tell them what to do. Give them hints but allow them to finally figure it out themselves.

Help the other team members welcome the newcomer

There is two sides of the coin when someone joins a team. The team needs to have the tools to welcome the new developer as well.

Let them pick up a small task or two

Allow them to add something new and visible to the project that is demo-able. When it is demoed, call out who did it and what a good job they did. This can really boost self-esteem. The faster they feel like they are adding value, the faster they feel they are part of the team. The faster they will feel empowered to do the best they can.

Encourage them to getting into harder tasks once they feel more and more comfortable

Good candidates will do this naturally.


答:
Don't explain only the good practices and standards of coding, but explain how the read code is structured. Explain what the software is supposed to do and how this is or will be achieved.

They will not understand until there is some job to do, so I suggest will to split into two parts, one before they start the real work, and the part two, after they started to work. They will look in some code or documentations and think "WTF!?". When this occurs, someone will be accompanying them and explaining the minor details.


答:
I think just assign some small tasks, ask them to write a few unit tests, make them debug some regression fails. Nothing too big or demanding, but enough to have them on their feet.

You should also assign a senior developer, preferably per new developer who could help mentor the candidate.

And yes, make them document what they are learning about the system. I am assuming here that you have some sort of internal wiki pages. If not it's definitely a must in both the long and short run - surprisingly fast way to have people ramp up. Wiki pages should not contain just the code documentation, but also stuff like known limitations (this is software :D), workarounds, time/memory performance metrics etc.


问:
Should an analysis be technology-agnostic?
I had an argument yesterday with one of my colleagues. He (a business-analyst, previously a programmer) thinks that he should be aware of the technology used to implement the system, so he can take better design decisions. In my opinion (I am a programmer), an analysis should not be coupled in any way to the technology and I believe that a good analyst can make a great design without worrying about the implementation details.

Am I right to think that way? Are there any reasons why a business analyst would need to know the technology used to implement the system?

EDIT : I believe that I used the wrong term when saying business analyst. Maybe I meant architect, or system analyst. I am not used to these terms. I meant something like architect or system analyst if you prefer.

Thank you everyone for your awesome answers! I am not very experienced yet and I am glad you opened my eyes on this.

答:
Each technology has limits and constraints, therefore it makes some sense for an analyst to consider those limits. On the other hand, an analyst who know .net well, but hasn't seen Java since the late nineties, will most likely design a .net solution - using .net terminology and design patterns - even if Java (or RoR etc.) would better fit the problem. It's relatively difficult to implement such a design in another technology later.

Therefore, I think an analyst should be agnostic when the technology hasn't been selected yet, but experienced in those cases where the choice has already been made.


问:
How a freelancer can learn industry standards?
Being a freelancer, I don't have access to corporate training programs where employees learn best practices. Most of the time I am advised to look into the available code on the Internet. Ideal places would be: CodePlex and SourceForge.

But this proves to be of limited rather very little help. I want my existing code to be analyzed and a better solution be suggested to improve the quality of the code.

How to learn coding that matches standards?

答:
The ideal solution is near you. There is a website called stackoverflow.com where thousand of fanatic developers are answering questions for free. Just for what is called reputation points. That website is full of extremely experienced professionnals and it's not very common to meet people like Jon Skeet the author of C# In Depth.

Your strategy? Try to answer to questions you know the answer, but also consult questions you may be interested in, such as the ones that talk about industry standards.

It is becoming so huge, that now I skip google, and search directly on stackoverflow.com.


答:
If the technology that will be used is known it should be taken into consideration by analysts when creating the design. Different technologies do things differently and a design that doesn't take into account those differences is going to have problems.

However, business analysts shouldn't care about what technology is used, their job is to gather business rules and make them understandable to the technical team. Systems analysts/architects/designers or any other name they may be given should know the technologies being used and design around them because they should be the ones doing actual design, not business analysts.

Title: Should an analysis be technology-agnostic?

Body:
I had an argument yesterday with one of my colleagues. He (a business-analyst, previously a programmer) thinks that he should be aware of the technology used to implement the system, so he can take better design decisions. In my opinion (I am a programmer), an analysis should not be coupled in any way to the technology and I believe that a good analyst can make a great design without worrying about the implementation details.

Am I right to think that way? Are there any reasons why a business analyst would need to know the technology used to implement the system?

EDIT : I believe that I used the wrong term when saying business analyst. Maybe I meant architect, or system analyst. I am not used to these terms. I meant something like architect or system analyst if you prefer.

Thank you everyone for your awesome answers! I am not very experienced yet and I am glad you opened my eyes on this.


答: Different technologies can have very different cost and efficiency structures for solving a given problem.  These costs can include things such as hiring costs in the local area, energy and cooling costs for specific systems, existing code and existing equipment reuse possibilities, etc., etc.  So, yes, perhaps one can ignore these contraints and details of specific technologies if one is working on a project where cost and efficiency are not anywhere near as important as other considerations (such as in aviation safety, nuclear plant control, medical implants, etc.).  But for most business situations, management might care about the cost structure of the potential solutions versus the benefits of the system implementation.</p>


答:
There are certainly cases where it makes sense for a business analyst to understand the technology at least well enough to understand where it makes sense to question a business user about how important a particular feature would be.  For example, if the business is accustomed to the behavior of a fat client application while the new application is going to be web-based, it is likely that there will be many "requirements" that would be trivial in a fat client but relatively difficult with a web-based application.  If the business analyst understands whether a request from the business is going to be trivial for the development team or whether it is going to involve 20 hours of AJAX development, they can figure out whether it makes sense to just write down the requirement or whether it makes sense to engage the business in exploring alternatives. </p>

<p>For any given project, there are likely a large number of sets of requirements that would in reality satisfy the business by making various sorts of trade-offs.  The more understanding the business analyst has about what trade-offs they are making, the more likely that they're going to deliver a set of requirements that maximizes the benefit to the business while minimizing the cost.  </p>

Body:
There are certainly cases where it makes sense for a business analyst to understand the technology at least well enough to understand where it makes sense to question a business user about how important a particular feature would be.  For example, if the business is accustomed to the behavior of a fat client application while the new application is going to be web-based, it is likely that there will be many "requirements" that would be trivial in a fat client but relatively difficult with a web-based application.  If the business analyst understands whether a request from the business is going to be trivial for the development team or whether it is going to involve 20 hours of AJAX development, they can figure out whether it makes sense to just write down the requirement or whether it makes sense to engage the business in exploring alternatives.

For any given project, there are likely a large number of sets of requirements that would in reality satisfy the business by making various sorts of trade-offs.  The more understanding the business analyst has about what trade-offs they are making, the more likely that they're going to deliver a set of requirements that maximizes the benefit to the business while minimizing the cost.


问:
I can't draw. How can I make polished applications?
I'm not a graphic designer. I'm pretty bad at drawing anything. I struggle to build things that look even as nice as "sample" applications bundled with development tools; primarily because I don't have squat in the way of art assets.

What strategies might I take to mitigate this?

答:
If you’re looking for graphical assets there are a few websites which collect high-quality graphics for free use:

Bootstrap for arguably the best (but definitely the hottest right now) UI web framework

Glyphicons for an icon set that complements Twitter’s Bootstrap UI framework

Subtle Patterns for, well, subtle background patterns

FamFamFam’s Silk icons which get used in a lot of software all over

Creative Market for diverse elements

And many more, such as the GNOME art project which includes lots of free graphical assets as well.

Not being the least bit creative, and having no education in design, I always strive on the side of conservativism: use established patterns (i.e. frameworks) and deviate as little as possible from trodden paths. This won’t necessarily be very interesting but at least you minimise your chance of failure and UX disaster.

Picasso said that “great artists steal” but in reality it’s mostly the talentless hacks, and look where this has led Microsoft and Samsung: to great-selling platforms.


答:
I believe there is a point between the two lines of thought that is probably more realistic.  While a high-level design might be best when kept technology agnostic, there must be a consideration of known real-world constraints and requirements that should be incorporated into the design.  What level is this design?  Do you have sufficient requirements?  How flexible is the environment?  Is management invested in a specific technical direction?

Are there no operational parameters that drive you in a specific direction?  Do you have a broad array of resources capable of implementing a solution in any technology stack?  Are there interoperability issues requiring access to other systems?

Answers to these questions are needed before you can definitively say whether the technology should be a part of the equation or whether the design should drive the technology selection.

Given no constraints and being a very high-level design, I might agree with your thinking that the design be truly agnostic.  However, in my 20+ years of experience, I've rarely been in a situation where there were not any constraints that limited my choices -- and which drove my design toward specific technologies or technology families.


问:
DDD + POCO does this makes sense?
DDD promotes rich domain models with behavior in it, POCO naked objects without any objects in it. Is it possible to have them both combined?

I have a Multi Layer Solution

Core - has POCO Entieties, interfaces for Repositories and Services

Data - Repository implementations

Service - Service Implementations

Infra - IoC Locator/registrar, viewmodels, (could be merged to webui)

WebUI - asp.net mvc presentation layer

I was saying that I use DDD but recently I've been told that I'm not because my Entities don't have behavior, is this true?

答:
POCO and DTO are two different things. DDD experts used POCO to differentiate from the initial EntityFramework model where your Entities had to extend EntityObject or implement a specific interface. As of 4.1 Entity Framework also supports POCO for persistence allowing for richer behavior and a more domain-centric approach to developing your business objects. DTOs are plain dumb data objects that don't have behavior (usually for transfer between two layers of an application).

Personally, I don't use DTOs at all anymore, when my UI communicates with the business layer, I expect View Models which have interaction logic embedded in them along with the data. This approach works with ASP.NET MVC applications as well as Rich/Smart Clients accessing restful services over the web. Behind the Service Layer, queries from the client are translated from Domain Entities to VMs and inbound commands are translated to actions against the Domain. Thus the client is shielded from the details/intricacies of the Domain and the Domain isn't corrupted by client/display concerns.

OwnerDisplayName: Omu

Title: DDD + POCO does this makes sense?


问:
Getting started with ClojureScript and Google Closure
I would like to investigate whether ClojureScript, with the associated Google Closure library is a reasonable tool to build modern, in-browser, Javascript applications.

My current Javascript stack consists of jQuery, Backbone and RequireJS with the possible additions of some widgets libraries like jQueryUI or KendoUI. So it will be quite a big leap (I already know how to work in Clojure, although I have little experience).

What is a good roadmap to do so? Should I learn the Google Closure library first, or can I grasp it together with ClojureScript?

One thing I am concerned about is the overall application structure. Backbone is rather opinionated on how to organize your application. I am not sure whether Google Closure also includes some components to help with the design of the application. And, if this is the case, I do not know how to tell whether this structure will port to ClojureScript or a ClojureScript application will require a different organization anyway, and only use - say - the widgets and DOM manipulation features of Closure.

答:
I say you have to sharpen your Clojure experience first, Google Closure after all is a JavaScript library and some other tools.

However, you need you check ClojureScript One:

ClojureScript One will show you how ClojureScript reduces the complexity of web development by allowing you to write applications using one language to unify development across the client and the server


答:
The business analyst should know what kind of application that we are developing like *Web application / Console application / Mobile application / Reporting application etc* so that she can better come up with a nice set of features for the application or pushing back on the user on impossible expectations like 3rd level nested drag and drop (e.g) .

He/She does not need to be aware of which technology like Java/C#/Python/SQL etc.


问:
How should I refactor so that responsibility for a geocoding service is shared appropriately?
First, some background. I have an application that requires the use of several external geocoding providers which I don't control. It uses a central service layer inside the application to dispatch to the appropriate provider.

I have a number of classes that are arranged in this way:

GeocodingService: Responsible for dispatching a request to geocode something to an appropriate provider.

Has one public method, geocode, that accepts a GeocodingService::Request and returns a GeocodingService::Response.

Each response includes: the latitude of the geocoded query, the longitude of the geocoded query, and a list of address components for the address where the query was found (e.g., an address component for "123", one for "Main Street", one for "Paris", and so on).

GeocodingService::AddressComponent: A single segment of an address that contains the segment's name, its abbreviation, and its kinds. For example, France has a name of France, an abbreviation of FR, and is a country and a political segment.

AddressComponent is responsible for checking that the types an instance is set with are not outside the boundaries of certain tracked types.

Address: Domain model for addresses, containing both a preferred mailing address (a list of string lines) and a list of address components (a list of GeocodingService::AddressComponents).

My question is: where should AddressComponent live -- as a service class (like it does now), or with my other domain models?

If it lives in the service, then life is straightforward. But that seems wrong, because now a domain model has to depend on a service's definition of an address, and it seems like they should be independent.

If it lives as a full-fledged domain object, then doesn't that mean that the service is now coupled to a domain object? That also seems undesirable.

How do I resolve this impasse?

答: You need either an Adapter or Builder to construct your Address domain object from the GeocodingService::AddressComponent(s).  This is the point where you loosely couple the components while maintaining separation of concerns and cohesiveness.</p>


问:
Mobile Web Framework that will only control rendering and page transitions
I have been using jQueryMobile for a bit now, and there are some things I like about it and others I do not.

First I will give a bit of background.

I have a light weight mobile application that has a few configurations and 6 pages. Ideally I Would like to load all pages into the DOM (they interact with each other quite often and pages will be switched in the same frequency). The application will post for some JSON every n seconds and refresh the values on the page (yes it is primarily a information display app).

with the jQuery Mobile framework the only real thing I like is how easy it is to have a standardized UI a crossed all devices and browsers, I'm really not using too much else out of the framework other than the basic page navigation (if you are familiar with the framework; a bare-bone multi-page design is all i need).

Why I want to step away from jQueryMobile is how weighty it is. Not only do you need to include the mobile library, but also the base jQuery libraries. This I do not like because I'm not using jQuery anywhere else on the site.

Any suggestions on light-weight mobile frameworks that have a similar rendering as jQueryMobile?

答: I would suggest keeping whatever javascript you might already have and moving to HTML5. Most phone browsers are very compatable (about the same as desktop browsers or better) at using CSS3 and HTML5 elements. Plus, if the feature you are trying to add isn't supported the browser will just ignore it and fall back to default values allowing older phones to still work but without the flashy animations.</p>


问:
Replace Type Code with Class (From Refactoring [Fowler])
This strategy involves replacing the likes of this:

```<code>public class Politician
{
    public const int Infidelity = 0;
    public const int Embezzlement = 1;
    public const int FlipFlopping = 2;
    public const int Murder = 3;
    public const int BabyKissing = 4;

    public int MostNotableGrievance { get; set; }
}
</code>```

With:

```<code>public class Politician
{
    public MostNotableGrievance MostNotableGrievance { get; set; }
}

public class MostNotableGrievance
{
    public static readonly MostNotableGrievance Infidelity = new MostNotableGrievance(0);
    public static readonly MostNotableGrievance Embezzlement = new MostNotableGrievance(1);
    public static readonly MostNotableGrievance FlipFlopping = new MostNotableGrievance(2);
    public static readonly MostNotableGrievance Murder = new MostNotableGrievance(3);
    public static readonly MostNotableGrievance BabyKissing = new MostNotableGrievance(4);

    public int Code { get; private set; }

    private MostNotableGrievance(int code)
    {
        Code = code;
    }
}
</code>```

Why exactly is this preferable to making the type an enumeration, like so:

```<code>public class Politician
{
    public MostNotableGrievance MostNotableGrievance { get; set; }
}

public enum MostNotableGrievance
{
    Infidelity = 0,
    Embezzlement = 1,
    FlipFlopping = 2,
    Murder = 3,
    BabyKissing = 4
}
</code>```

There is no behavior associated with the type and if there was you would be using a different type of refactoring anyways, for example, 'Replace Type Code with Subclasses' + 'Replace Conditional with Polymorphism'.

However, the author does explain why he frowns on this method (in Java?):

Numeric type codes, or enumerations, are a common feature of C-based
  languages. With symbolic names they can be quite readable. The problem
  is that the symbolic name is only an alias; the compiler still sees
  the underlying number. The compiler type checks using the number 177
  not the symbolic name. Any method that takes the type code as an
  argument expects a number, and there is nothing to force a symbolic
  name to be used. This can reduce readability and be a source of bugs.

But when trying to apply this statement to C#, this statement doesn't appear to be true: it won't accept a number because an enumeration is actually considered to be a class. So the following code:

```<code>public class Test
{
    public void Do()
    {
        var temp = new Politician { MostNotableGrievance = 1 };
    }
}
</code>```

Will not compile. So can this refactoring be considered unecessary in newer high-level languages, like C#, or am I not considering something?

答: If there's no behavior associated with the value and there's no extra information that you need to store alongside it and the language doesn't support implicit conversion to integers, I would use an enum; that's what they're there for.


问:
Biggest mistake you've ever made
Similar to the question I read on Server Fault, what is the biggest mistake you've ever made in an IT related position. Some examples from friends:

I needed to do some work on a production site so I decided to copy over the live database to the beta site. Pretty standard, but when I went to the beta site it was still pulling out-of-date info. OOPS! I had copied the beta database over to the live site! Thank god for backups.

And for me, I created a form for an event that was to be held during a specific time range. Participants would fill out the form for a chance to win, and we would send the event organizers a CSV from the database. I went into the database, and found ONLY 1 ENTRY, MINE. Upon investigating, it appears as though I forgot an auto increment key, and because of the server setup there was no way to recover the lost data.

I am aware this question is similar to ones on Stack Overflow but the ones I found seemed to receive generic answers instead of actual stories :)

What is the biggest coding error/mistake ever…

答:
For a robot I work on, we keep a log file of every run. We have the robot and a simulator, both which generate these log folders. The simulator's log files are useless, but the robots log files are very useful and are stored forever.

Because the robot itself has limited hard drive space, they're transferred to another computer and stored there. This computer happens to be the main operating computer for communicating with the robot.

Well, I had just started working on the robot a couple months earlier and didn't know this. I thought the logs on the operating computer were the useless ones generated by the simulator and deleted them. We lost all of the old logs because there wasn't a proper backup.

Title: Biggest mistake you've ever made


答:
I think you've almost answered your own question there.

The second piece of code is preferred over the first because it offers type-safety. With the first piece, if you have a similar enumeration of Fish then you can say something like

```<code>MostNotableGrievance grievance = Fish.Haddock;
</code>```

and the compiler won't care. If Fish.Haddock = 2 then the above will be exactly equivalent to

```<code>MostNotableGrievance grievance = MostNotableGrievance.FlipFlopping;
</code>```

but obviously not instantly readable as such.

The reason enumerations are often no better is because the implicit conversion to and from int leave you with the exact same problem.

But, in C#, there is no such implicit conversion, so an enum is a better structure to use. You'll rarely see either of the first two approaches used.

Title: Replace Type Code with Class (From Refactoring [Fowler])

Body:
This strategy involves replacing the likes of this:

```<code>public class Politician
{
    public const int Infidelity = 0;
    public const int Embezzlement = 1;
    public const int FlipFlopping = 2;
    public const int Murder = 3;
    public const int BabyKissing = 4;

    public int MostNotableGrievance { get; set; }
}
</code>```

With:

```<code>public class Politician
{
    public MostNotableGrievance MostNotableGrievance { get; set; }
}

public class MostNotableGrievance
{
    public static readonly MostNotableGrievance Infidelity = new MostNotableGrievance(0);
    public static readonly MostNotableGrievance Embezzlement = new MostNotableGrievance(1);
    public static readonly MostNotableGrievance FlipFlopping = new MostNotableGrievance(2);
    public static readonly MostNotableGrievance Murder = new MostNotableGrievance(3);
    public static readonly MostNotableGrievance BabyKissing = new MostNotableGrievance(4);

    public int Code { get; private set; }

    private MostNotableGrievance(int code)
    {
        Code = code;
    }
}
</code>```

Why exactly is this preferable to making the type an enumeration, like so:

```<code>public class Politician
{
    public MostNotableGrievance MostNotableGrievance { get; set; }
}

public enum MostNotableGrievance
{
    Infidelity = 0,
    Embezzlement = 1,
    FlipFlopping = 2,
    Murder = 3,
    BabyKissing = 4
}
</code>```

There is no behavior associated with the type and if there was you would be using a different type of refactoring anyways, for example, 'Replace Type Code with Subclasses' + 'Replace Conditional with Polymorphism'.

However, the author does explain why he frowns on this method (in Java?):

Numeric type codes, or enumerations, are a common feature of C-based
  languages. With symbolic names they can be quite readable. The problem
  is that the symbolic name is only an alias; the compiler still sees
  the underlying number. The compiler type checks using the number 177
  not the symbolic name. Any method that takes the type code as an
  argument expects a number, and there is nothing to force a symbolic
  name to be used. This can reduce readability and be a source of bugs.

But when trying to apply this statement to C#, this statement doesn't appear to be true: it won't accept a number because an enumeration is actually considered to be a class. So the following code:

```<code>public class Test
{
    public void Do()
    {
        var temp = new Politician { MostNotableGrievance = 1 };
    }
}
</code>```

Will not compile. So can this refactoring be considered unecessary in newer high-level languages, like C#, or am I not considering something?

Body:
I think you've almost answered your own question there.

The second piece of code is preferred over the first because it offers type-safety. With the first piece, if you have a similar enumeration of Fish then you can say something like

MostNotableGrievance grievance = Fish.Haddock;

and the compiler won't care. If Fish.Haddock = 2 then the above will be exactly equivalent to

MostNotableGrievance grievance = MostNotableGrievance.FlipFlopping;

but obviously not instantly readable as such.

The reason enumerations are often no better is because the implicit conversion to and from int leave you with the exact same problem.

But, in C#, there is no such implicit conversion, so an enum is a better structure to use. You'll rarely see either of the first two approaches used.


问:
Should I contract someone to help me with an existing project?
I have a paid Android app that I made by myself this past summer and I've been working on it throughout the year. The app is geared toward a professional niche market (but there are people all around the world who would buy it,) so it's priced highly. It is

Mostly C++, some Java

Built heavily on Qt (in the C++ code)

15,000+ lines of code

Well commented in some places but not others

I enjoy working on it, but find I no longer have time to slog through the more "menial" coding work of maintaining it, and instead want to focus on building new components and taking it to the next level, where I think I would really get bigger returns. In order to do that, I'm looking at contracting out some programming work to someone else.

My app makes some money, but not enough to hire anyone steadily - instead I'll have to just give them smaller jobs to do at a time. I might have to hire someone in a lower economic status country as well, because I expect that rates, say, here in the U.S. won't be affordable to me. My knee-jerk reaction is to go to vWorker.com (formerly RentACoder) where I did a lot of work several years ago. Is this going to help me or cause more headache than help?

Here are some more specific questions I have - feel free to answer any that you have thoughts on. Also, please let me know how I can improve this question. Thanks in advance.

How can I find a person with the right skill set? Is asking for Qt and Android SDK experience going to increase the price a lot?

How can I protect my copyright? Is this enforceable in less economically developed countries? Or can someone easily get away with stealing my code and selling it themselves?

Are there any other issues you foresee in hiring this person, and how might I address those?

答:
That skillset is going to be hard to find on something like vWorker or any low rate contracting website. Especially since you chose C++ on the Android platform.

You can't. Unless you have the money to hire an attorney to enforce the NDA, the NDA will be useless.

Yes. Can you live off the money you are making from this product? If not, then I highly doubt you'll have sufficient funds to hire someone else to work on it. And you'll be paying significantly more in the long run if you keep changing contractors, because of the ramp up time.

Here is another way to look at things. Every hour you pay that other developer to work on your product, if it isn't bringing in at least twice that much in revenue, it's a waste of time and money. Will they be able to add enough value to the product to make it worth it? Based on everything you've said I doubt it.

You should do some internal reflection. Yes the menial things suck to do. Are you losing money because you have too much work to do and can't finish it all? If so, maybe it's time to find someone local that is willing to "invest" with you in the product. Maybe they sign on to get X% of the revenue. If you are not losing any money because you cannot add enough features then  the market for your product is stagnant. You should focus on figuring out what will get more people to buy it, then look at getting extra resources.

Contracting this out, especially to the likes of RentACoder is the #1 way for someone else to steal your application, and for you to waste money for little in return.


答:
How can I find a person with the right skillset? Is asking for Qt and Android SDK experience going to increase the price a lot?

You will have to publish the required skills across different boards vWoerker, GURU, etc. Finding the person with the correct skills who would be interested is an issue. You have to make interviews, ask questions, etc. You  also have to make an attractive offer and make it somewhat attractive to join.

How can I manage intellectual property? Is an NDA enforceable in less economically developed countries? Or can someone easily get away with stealing my code and selling it themselves?

Contracts and copyrights don't matter unless you wish to go to court with an evidance. Is it economically feasible for you to sue someone in a foreign country? Do you think they will ever pay?

Are there any other issues you foresee in hiring this person, and how might I address those?

A - Reliability. If this person is not with great interest to do a good work then you will be in the same situation you are in now frequently.

B - Trust. It is not going to be easy to ensure that this person will not alter parts of the application in an undesired way.

C - Control. I don't think you will be able to force the contracted person to deliver or do the testing the way you want.

D - Time zone. If you are hiring someone in a different time zone, communication will not be as smooth. Communication may be an issue.

E - Initiation. You will be answering many question from the contracted person and this will probably waste a lot of your time until he/she becomes familiar with your code.

Title: Should I contract someone to help me with an existing project?

Body:
I have a paid Android app that I made by myself this past summer and I've been working on it throughout the year. The app is geared toward a professional niche market (but there are people all around the world who would buy it,) so it's priced highly. It is

Mostly C++, some Java

Built heavily on Qt (in the C++ code)

15,000+ lines of code

Well commented in some places but not others

I enjoy working on it, but find I no longer have time to slog through the more "menial" coding work of maintaining it, and instead want to focus on building new components and taking it to the next level, where I think I would really get bigger returns. In order to do that, I'm looking at contracting out some programming work to someone else.

My app makes some money, but not enough to hire anyone steadily - instead I'll have to just give them smaller jobs to do at a time. I might have to hire someone in a lower economic status country as well, because I expect that rates, say, here in the U.S. won't be affordable to me. My knee-jerk reaction is to go to vWorker.com (formerly RentACoder) where I did a lot of work several years ago. Is this going to help me or cause more headache than help?

Here are some more specific questions I have - feel free to answer any that you have thoughts on. Also, please let me know how I can improve this question. Thanks in advance.

How can I find a person with the right skill set? Is asking for Qt and Android SDK experience going to increase the price a lot?

How can I protect my copyright? Is this enforceable in less economically developed countries? Or can someone easily get away with stealing my code and selling it themselves?

Are there any other issues you foresee in hiring this person, and how might I address those?


答: The ideal user interface would be where the user thinks a thought, and what they wanted done is simply done. Anything short of that is crippled by the technology limitations we have at our disposal, so of course the BA needs to understand what context they can design the system in.


答:
Odesk.com - $10-$20 hour.

IP and NDA... in what? A tiny smartphone app? Be serious. So you're going to file patent claim for several hundreds of thousands $$ to protect your "IP"? Or you're going to stalk the developer after he finish work for you to enforce NDA? Copyright protection is free and it's enough.

Speculative "for free" work? So you're going to give your code to some 15 y/o kid and you expect him to work for undefined % of undefined "profits"? Even "better" idea!

vWorker.com (formerly RentACoder) where I did a lot of work several years ago.

Done some work there too. I think the site changed. Now (in my opinion) is targeted at... workers (typists, seo experts that write bad articles) anyway... no one sane will work there for $4 i think all pro's abandoned the site as work that gets posted there now is just a big JOKE.


答:
Having worked both sides of this issue I have to agree with the Analyst.  I have seen some spectacularly poor designs resulting from lack of understanding of the capabilities of the technology.  In some cases, it has been a result of taking marketing hype as truth.  In general, the problem has been generating specifications which don't match the technical capabilities.

The analyst should be specifying What needs to be done, When, and by Whom.  They should know Why it is being done.  Development priority should be more dependent on the Why than the other factors.  The design and development team need to handle the How.  In order to develop cost effective systems, the analysts need to specify what needs to be done in terms that don't push the boundaries of the available technology.

Pushing the boundaries can increase costs in a number of ways, but in some cases may have a significant return.  Some of the cost factors are:

Experimentation may be required to develop a working solution;

New employees or consultants with specialized knowledge may need to be acquired;

Training on the new technology may be needed;

Development tends to be slower and bug rates higher; and

Extra efforts may delay simpler solutions which have more immediate value.


问:
Stuff every programmer needs while working
I've been tasked with creating a fun and relaxing environment, one thing I know that I want is ergonomic mice and keyboards, others have suggested exercise balls and bands.

What is it that every programmer needs while working? What might not be necessary but would be nice to have anyway?

Note: this question was asked previously, but has been recommended to be posted here. See this link for the previous responses: https://stackoverflow.com/questions/3911911/stuff-every-programmer-needs-while-working-closed

答:
A fast Computer

A good internet connection( can't see that loading sign for too long )

Liberty to wear what I want ( ofcourse in a limit )

That much would be sufficient :)


问:
Why the static data members have to be defined outside the class separately in C++ (unlike Java)?
```<code>class A {
  static int foo () {} // ok
  static int x; // <--- needed to be defined separately in .cpp file
};
</code>```

I don't see a need of having A::x defined separately in a .cpp file (or same file for templates). Why can't be A::x declared and defined at the same time?

Has it been forbidden for historical reasons?

My main question is, will it affect any functionality if static data members were declared/defined at the same time (same as Java) ?

答:
Its required because otherwise the compiler doesn't know where to put the variable. Each cpp file is individually compiled and does not know about the other. The linker resolves variables, functions, etc. I personally don't see what the difference is between the vtable and static members (we don't have to choose what file the vtable are defined in).

I mostly assume it is easier for compiler writers to implement it that way. Static vars outside of class/struct exist and perhaps either for consistency reasons or because it would be 'easier to implement' for compiler writers they defined that restriction in the standards.


问:
How to get new team members up to date with the project?
We are about to hire 1-2 new engineers for the software team (consisting of 3 developers, 1 tester).

What are the steps to integrate them into the team?

My ideas are :

read documentation (coding standards, documents in development methodologies we use)

get them to read the existing code

assign them some simple tasks

at the end, make them responsible for the code part

What else could we do?

The project is in a medical sector (ultrasound system), and is already 5 years going. We have yearly releases, and we are about to finish one release, when we want to add 1-2 engineers.

The project is in the maintenance phase (refactoring legacy code, plus adding new features). Things are pretty much on schedule (more or less).

答: As the Lead, I spend at least 2 days with new developers. I've found that developing a relationship in which it feels comfortable to ask the inevitable question "how is your progress?" is a MUST. There is fear in any new community to fit in... we hide mistakes, act perfect, make things better than they are, lessen difficulty. A manager spending 2 days with someone will let them know that's not what their culture is about, and allows them to lead by example. New coders need a history lesson about where you came from and how far you are along. Documents just don't do the task justice.</p>


答:
There is a great difference between C++ and Java.

Java operates on his own virtual machine that creates everything into its own run-time environment. If a definition happens to be seen more than once, will simply act on the same object the runtime environment ultimatelly knows.

In C++ there is no "ultimate knowledge owner": C++, C, Fortran Pascal etc. are all "translator" from a source code (CPP file) into an intermediate format (the OBJ file, or ".o" file, depending on the OS) where statements are translated into machine instruction and names becomes indirect addresses mediated by a symbol table.

A program is not made by the compiler, but by another program (the "linker"), that joins all OBJ-s together (no matter the language they come from) by re-pointing all the addresses that are towards symbols, towards their effective definition.

By the way the linker works, a definition (what creates the physical space for a variable) must be unique.

Note that C++ does not by itself link, and that the linker is not issued by C++ specs: the linker exist because of the way the OS modules are built up (usually in C and ASM). C++ has to use it the way it is.

Now: a header file is something to be "pasted into" several CPP files.
Every CPP file is translated independently of every other one.
A compiler translating different CPP files, all receiving-in a same definition will place the "creation code" for the defined object in all the resulting OBJs.

The compiler doesn't know (and will never know) if all those OBJs will ever be used together to form a single program or separately to form different independent programs.

The linker doesn't know how and why definitions exist and where they come from (it even doesn't know about C++: every "static language" can produce definitions and references to be linked). It just knows there are references to a given "symbol" that is "defined" at a given resulting address.

If there are multiple definitions (don't confuse definitions with references) for a given symbol, the linker has no knowledge (being language agnostic) about what to do with them.

It is like merging a number of city to form a big town: if you're found having two "Time square" and a number of people coming from outside asking to go to "Time square", you cannot decide on a pure technical basis (without any knowledge about the politics that assigned those names and will be in charge to manage them) in which exact place to send them.

Title: Why the static data members have to be defined outside the class separately in C++ (unlike Java)?

Body:
```<code>class A {
  static int foo () {} // ok
  static int x; // <--- needed to be defined separately in .cpp file
};
</code>```

I don't see a need of having A::x defined separately in a .cpp file (or same file for templates). Why can't be A::x declared and defined at the same time?

Has it been forbidden for historical reasons?

My main question is, will it affect any functionality if static data members were declared/defined at the same time (same as Java) ?


问:
Design Patterns for Coordinating Change Event Listeners
I've been working with the Observer pattern in JavaScript using various popular libraries for a number of years (YUI & jQuery). It's often that I need to observe a set of property value changes (e.g. respond only when 2 or more specific values change). Is there a elegant way to 'subscribe' the handler so that it is only called one time? Is there something I'm missing or doing wrong in my design?</p>

答:
I don't know, if this idea exists already and if it has a name - if so, it would be cool if anybody tell it to us :-)

You could add an object which

observes your two or three values,

is observed by your aim object and

only sends a message, if your condition is reached.

This sounds to me like an "conditional observer proxy".


问:
Career advice: PhD in theory of programming languages
I'm very interested in the theories of programming languages and going to apply a PhD in this topic, but I want to know more about the career after the graduate education. besides being a professor, but also what occupation can I get?</p>

答:
Lots of jobs available:

C#/.NET at Microsoft

Java at Oracle

Perl6 (won't get much pay I think)

ActionScript at Adobe


答:
I think the limitation you have considered is not related to semantics (why should something change if the initialization were defined in the same file?) but rather to the C++ compilation model which, for reasons of backward compatibility, cannot be easily changed because it would either become too complex (supporting a new compilation model and the existing one at the same time) or would not allow to compile existing code (by introducing a new compilation model and dropping the existing one).

The C++ compilation model stems from that of C, in which you import declarations into a source file by including (header) files. In this way, the compiler sees exactly one big source file, containing all the included files, and all the files included from those files, recursively. This has IMO one big advantage, namely that it makes the compiler easier to implement. Of course, you can write anything in the included files, i.e. both declarations and definitions. It is only a good practice to put declarations in header files and definitions in .c or .cpp files.

On the other hand, it is possible to have a compilation model in which the compiler knows very well if it is importing the declaration of a global symbol that is defined in another module, or if it is compiling the definition of a global symbol provided by the current module. Only in the latter case the compiler must put this symbol (e.g. a variable) in the current
object file.

For example, in GNU Pascal you can write a unit a in a file a.pas like this:

```<code>unit a;

interface

var MyStaticVariable: Integer;

implementation

begin
  MyStaticVariable := 0
end.
</code>```

where the global variable is declared and initialized in the same source file.

Then you can have different units that import a and use the global variable
MyStaticVariable, e.g. a unit b (b.pas):

```<code>unit b;

interface

uses a;

procedure PrintB;

implementation

procedure PrintB;
begin
  Inc(MyStaticVariable);
  WriteLn(MyStaticVariable)
end;
end.
</code>```

and a unit c (c.pas):

```<code>unit c;

interface

uses a;

procedure PrintC;

implementation

procedure PrintC;
begin
  Inc(MyStaticVariable);
  WriteLn(MyStaticVariable)
end;
end.
</code>```

Finally you can use units b and c in a main program m.pas:

```<code>program M;

uses b, c;

begin
  PrintB;
  PrintC;
  PrintB
end.
</code>```

You can compile these files separately:

```<code>$ gpc -c a.pas
$ gpc -c b.pas
$ gpc -c c.pas
$ gpc -c m.pas
</code>```

and then produce an executable with:

```<code>$ gpc -o m m.o a.o b.o c.o
</code>```

and run it:

```<code>$ ./m
1
2
3
</code>```

The trick here is that when the compiler sees a uses directive in a program module (e.g. uses a in b.pas), it does not include the corresponding .pas file,
but looks for a .gpi file, i.e. for a pre-compiled interface file
(see the documentation).
These .gpi files are generated by the compiler together with the .o files when each module is compiled.
So the global symbol MyStaticVariable is only defined once in the object file a.o.

Java works in a similar way: when then compiler imports a class A into class B, it looks at the class file for A and does not need the file A.java. So all definitions and initializations for class A can be put in one source file.

Going back to C++, the reason why in C++ you have to define static data members in a separate file is more related to the C++ compilation model than to limitations imposed by the linker or other tools used by the compiler.
In C++, importing some symbols means to build their declaration as part of
the current compilation unit. This is very important, among other things,
because of the way in which templates are compiled. But this implies that you cannot / should not define any global symbols (functions, variables, methods, static data members) in an included file, otherwise these symbols could be
multiply-defined in the compiled object files.

Body:
I think the limitation you have considered is not related to semantics (why should something change if the initialization were defined in the same file?) but rather to the C++ compilation model which, for reasons of backward compatibility, cannot be easily changed because it would either become too complex (supporting a new compilation model and the existing one at the same time) or would not allow to compile existing code (by introducing a new compilation model and dropping the existing one).

The C++ compilation model stems from that of C, in which you import declarations into a source file by including (header) files. In this way, the compiler sees exactly one big source file, containing all the included files, and all the files included from those files, recursively. This has IMO one big advantage, namely that it makes the compiler easier to implement. Of course, you can write anything in the included files, i.e. both declarations and definitions. It is only a good practice to put declarations in header files and definitions in .c or .cpp files.

On the other hand, it is possible to have a compilation model in which the compiler knows very well if it is importing the declaration of a global symbol that is defined in another module, or if it is compiling the definition of a global symbol provided by the current module. Only in the latter case the compiler must put this symbol (e.g. a variable) in the current
object file.

For example, in GNU Pascal you can write a unit a in a file a.pas like this:

unit a;

interface

var MyStaticVariable: Integer;

implementation

begin
  MyStaticVariable := 0
end.

where the global variable is declared and initialized in the same source file.

Then you can have different units that import a and use the global variable
MyStaticVariable, e.g. a unit b (b.pas):

unit b;

interface

uses a;

procedure PrintB;

implementation

procedure PrintB;
begin
  Inc(MyStaticVariable);
  WriteLn(MyStaticVariable)
end;
end.

and a unit c (c.pas):

unit c;

interface

uses a;

procedure PrintC;

implementation

procedure PrintC;
begin
  Inc(MyStaticVariable);
  WriteLn(MyStaticVariable)
end;
end.

Finally you can use units b and c in a main program m.pas:

program M;

uses b, c;

begin
  PrintB;
  PrintC;
  PrintB
end.

You can compile these files separately:

$ gpc -c a.pas
$ gpc -c b.pas
$ gpc -c c.pas
$ gpc -c m.pas

and then produce an executable with:

$ gpc -o m m.o a.o b.o c.o

and run it:

$ ./m
1
2
3

The trick here is that when the compiler sees a uses directive in a program module (e.g. uses a in b.pas), it does not include the corresponding .pas file,
but looks for a .gpi file, i.e. for a pre-compiled interface file
(see the documentation).
These .gpi files are generated by the compiler together with the .o files when each module is compiled.
So the global symbol MyStaticVariable is only defined once in the object file a.o.

Java works in a similar way: when then compiler imports a class A into class B, it looks at the class file for A and does not need the file A.java. So all definitions and initializations for class A can be put in one source file.

Going back to C++, the reason why in C++ you have to define static data members in a separate file is more related to the C++ compilation model than to limitations imposed by the linker or other tools used by the compiler.
In C++, importing some symbols means to build their declaration as part of
the current compilation unit. This is very important, among other things,
because of the way in which templates are compiled. But this implies that you cannot / should not define any global symbols (functions, variables, methods, static data members) in an included file, otherwise these symbols could be
multiply-defined in the compiled object files.


答:
The analysis process itself needs to be entirely technology-agnostic. When you are researching the client and its needs, you need to do so with a completely open mind. The other side of the coin however, is that the analyst is often asked to provide recommendations and may also be required to handle system architecture also. This is an entirely different facet of the role in which a wider understanding of the available technologies is crucial, as it can make a huge difference to the customer not only in terms of the ability to get a project off the ground, but also in terms of the long term needs of the customer, and the sustainability of the project itself.

While it's true that the larger part of designing software is essentially the same regardless of the technology used, there are always areas where the design will be influenced by the choice of technology. Platform choices may influence language and API choices, while availability of expertise, support, and even cost will also have an impact on the choices made. So from one perspective, part of your position is justified in that the actual analysis should be conducted without the influence of any specific technology, however using the analysis to determine a design will always require a broader technology knowledge, so that the analyst can make recommendations which will allow the application of designs intended to meet the customer's needs.