问:
Branding websites aimed for mobile devices
I'm currently working on a website which is also supposed to be mobile optimized.

My client has provided me with a layout of how the mobile version of how the website should look like. Making their design wish come true is no biggie, but making the design fit the screen is my issue. Right now I'm facing some issues regarding the width on the  tag of the site, as the design is measured to a width of 640px, but that leaves a big gap on the right side of the screen on e.g. iPhones and Android phones.

The website is being developed in ASP.NET and C#. We're only using 1 masterpage, thus the optimizing can be tricky. The design I've been provided with is a .psd file which I'm supposed to just slize up and take images etc. directly out of. Problem is all the navigation images, content dividing images etc. are all in specified widths and heights, thus I've put the width of 640px on the  tag.

So my question really is, what's the best way of fitting a design to a handheld screen? Should I forget all about pixels, em and inches and go all the way with % for both width, font-size etc? Or can I just "copy/paste" the provided design and some how force the screen resolutions on the phones to fit their zoom to the width of the 640px body width without leaving gaps of space in either sides of the screen?

答:
Actually, those "wide gaps" are helpful since it prevents accidental clicking from gripping the device. Having a gutter for thumbs is especially helpful on tablets in landscape orientation. If you haven't used an iPad or Android tablet yourself, try one so that you can get a feel for this.

Don't use a fluid layout. This tends to break pinch-zoom and landscape/portrait orientation flips, two important aspects of the mobile UX. My wife, who is an avid tablet user, really hates sites that do this. From what I've observed, breaking basic mobile functionality is the worst thing for tablet users, closely followed by overly watered down mobile sites.

I've been using the somewhat standard 960 layouts (960 Grid or CSS Blueprint) and using 1 or 2 columns on either side as gutter space. These systems make placement, especially with ASP.NET master pages, easy to do.


问:
Are there any best practices regarding the handover from architecture to development?
We are looking at improving the process for handing over tasks from architecture to development.

At one end of the scale it there is no architecture guidance you risk getting chaos, with each developer doing things his way.

At the other end of the scale where everything is specified, the specification takes longer than the development, and you risk having very boring development tasks.

Has anyone found an optimal middle ground between these extremes? Which artifacts do you deliver to development? For example: modules, class structure, or sequence diagrams?

答:
I will start out by saying that the very concept of a seperate "Architecture" team is an affront to good software development practices.  Architecture teams in corporate environments tend to be a culmination of the worst ivory-tower pseudo-intellectual bull** artists that can be found amongst the pool of developers.

Other organizations treat Architecture groups like a political reward and justification for a massive salary to the most senior members regardless of merit, knowledge or skill.  Most consist of both types.

Every developer can and should be an architect and should be involved in the high level designs of a company.  The very thought that a single group has complete dictatorial control over every aspect of software design and that must be handed off to developers who didn't contribute to the design, don't understand the reasoning behind the design choices, and may understand critical flaws in the design being more comfortable and closer to the actual implementation and existing code, is frankly completely flawed from its very core, and will consistently result in one of three scenarios:

Developers do not comprehend the design, or outright reject it due the realities of the current implementation, and end up determining their own undocumented design and implementing that instead.  The situation is formal design documents that do not reflect the implementation of the software.

The developers blindly follow the design that may or may not take current requirements or unique aspects of user stories into consideration, resulting in a buggy and poor quality implementation.

Intelligent developers who understand the design documents, and are able to implement them, quickly get bored with not being involved in design discussions.  They are either likely excluded from participating in the Architecture group due to political or seniority issues, so they become frustrated, bored, and leave for greener pastures.  This negatively affects the project resulting in a brain drain causing the vicious cycle of poor software quality to continue.

The single best way to mitigate this problem is CHANGE the Architecture group and possibly put them in tech lead positions.  The role of the Architecture group should be more or less a "scrum of tech leads" if you will.  They should only rarely meet and only discuss the highest level technical direction issues, Eg. think discussion migrating from Java to Scala, Abandoning Oracle for MySQL, possibly writing common utility libraries that mandate a certain TYPE of design process over another, switching from StarUML to Altova UML.

Actual and real software design will be a community process involving ALL software developers, laid out by the extremely high level direction of the Architecture group.

ContentLicense: CC BY-SA 3.0


问:
How do I add another script engine to web browsers under Linux / Windows / Mac?
In my ample (NOT!) spare time, I'm fiddling with Lhogho and wondering how to go about morphing it into a script engine for web browsers, viz

```<code><h1>My First Web Page</h1>

<script type="text/lhoghoscript">
   print [Hello World]
</script>

</body>
</html>
</code>```

Any suggestions where to start? For Windows, I suppose Microsoft Windows Script Interfaces - Introduction. What about Linux and Mac?

On the way there, I'm also trying to figure out how to make Lhogho into a server-side language, rather like PHP or ASP, viz

```<code><head>
<title>Lhogho Preprocessor</title>
</head>
<? print [Hello world] ?>

<body>
</body>
</html>
</code>```

I figure that'll be slightly easier. Maybe.

答:
I would suggest writing a Javascript Lhogho interpreter or a compiler to Javascript for embedding in browsers- processing.js or Dart use these strategies to get their language into browsers.

For instance, if you implement a Lhogho compiler using LLVM, you can use emscripten to turn LLVM bytecode into Javascript. Thus, you could write a preprocessor that turned Lhogho -> LLVM bytecode -> Javascript.

For server-side stuff, you are right, it's easier. You might start with CGI ( http://en.wikipedia.org/wiki/Common_Gateway_Interface ). CGI describes how a web server can invoke an external program to generate server-side content. If Lhogho programs can be invoked as external programs, you could do server-side Lhogho programming without much effort, and research how to make it "nicer" (raw CGI is pretty uncomfortable). Alternatively, you might want to try FastCGI ( http://en.wikipedia.org/wiki/FastCGI ), which offers better performance.


问:
Tools to help Agile team deliver value
My Agile team is following practices of XP like pair programming(J2EE), 45 work hours/week, TDD etc. Do you have any recommendations of open source tools (dev, test & build integration) and templates(user story, burndown charting) etc. for enabling my team to focus on business value delivery. I am the iteration manager and we have tried Hudson, Junit and Selenium.</p>

答:
We use a combination of FogBugz and Stefan Rusek's excellent Kanban board. FogBugz handles ticket tracking, burndown charts (and much more), and recently they've added Kiln, which is an integrated, hosted Mercurial.

http://www.fogbugz.com

Also, though I haven't tried it, I understand some smart Java folk I know are interested in JBehave, a BDD framework for Java.

http://www.jbehave.org

I wholeheartedly concur with @Guillaume's much more thorough response. I would add one thing to that however, though I'm in danger of stating the obvious:

For agile to work, you have to write user stories to express the functionality you want. Perhaps what I really mean is that you can't let people only write old school functional specifications and expect agile to work. The user story really is the basic building block for the whole thing.

Title: Tools to help Agile team deliver value


问:
Is it ethical to use personal code at work?
I am working on a side project at work where I find it beneficial to use some of my code that I have developed personally (outside of work) to speed my development. My side project is developing a C++ GUI application to let our power users run queries (built by me) against databases on several different platforms (DB2, Oracle, SQL Server and MySQL). In the past, I would usually just run these myself on request or build an Excel VBA application for them. Now that I have built several VBA applications for several different people, I find the need to build one central application that just reads in custom .sql files and executes against various databases.

The application that I am building is in C++ and uses an LGPL cross-platform GUI toolkit. However, I have a lot of code that in my own libraries that I have built over the years on leisure, non-work related projects. Is it okay to use this code at work, thus saving me (and the company) time? If so, can I port any bug fixes and enhancements back to my personal library? There seems to be a line that I do not know when I am going to cross it.

I just want to add that none of the personal code has anything to do with any business logic. They are just basic utility classes/wrappers.

答:
It's totally ethical.  I often research new technologies and different ways of doing things at home, and more than once I've developed something at home that I wound up using in my work.  I also wouldn't have any problems with bringing fixes or enhancements back home (or bringing them from home to work).

I'd only be concerned if you intended to release your work independently.  If that's the case, then I wouldn't bring it in at all, and I wouldn't even try to re-use the design.  As others have stated, check your employment contract and discuss it with your manager.  If you don't have one of those "you work for us 24/7"-type contracts, then you could consider releasing your code under some license and using only the released code at work.  Then it wouldn't really be any different from using an open-source or free software project, which I assume you're already able to do.

OwnerDisplayName: CodeBlew


问:
Using a standard localised data cryptography pattern with an ASP.NET MVC3 application
I have been given the task to rejuvenate an existing Human Resources application from Access into ASP.NET. This is a strictly internal application, and I have no problems developing it within our standard ASP.NET environment. It does however pose it's own problems, both technically and ethically.

The HR app will be responsible for storing employee pay data, for which it is not appropriate for me, the developer, to see. It's essentially three fields (salary band, actual salary, comments) and four other values, calculated on the front end.

I'd like to go down the cryptography route to encrypt said data - cryptography with the .NET Framework is very easy to implement. I could "roll my own", which as we all know is a bad idea. However I was wondering if there was a more better way of doing it. Here are some points:

For starters, we're all attached to the same domain.

I've heard and read about Certificates, can they be useful here? (x.509?)

The data will be stored in our local SQL Server, obviously the actual data here needs to be encrypted, so can SQL Server help me? Certificates again?

If a user doesn't have the appropriate certificate, can the data just be null? (You can't see this matey!)

This encryption problem doesn't have any relevance to usage of the system via a permissions model.

答:
Your comments indicate that you are "writing the system in its entirety which means I have access to everything".  Can you not lean on your IT team here?

Ask a current user of the Access database to make a copy of it and replace everyone's salary with $10,000 (for instance).

Develop the application on your workstation or on a development server.

Provide a proper security model to ensure that the correct users (aka not you) can see what they need to see

Provide a tool to allow an administrative user to enter the proper salaries

Get IT to deploy the application and enable something like SQL Server's TDE on the production version

Additionally, using something like Microsoft's WIF or ADFS to provide single sign on is also a good idea given that you indicate your users are on the same domain.


问:
Should I develop a product with minimal use so I can say I developed it?
I appear to have done something wrong here, so let me try to rephrase this more simply so I stop giving the wrong impression.

I'm in the planning stages of a project right now, on my own time; I'm currently defining the scope of the project. I can see this application also releasing an Android app; furthermore, I've long wanted to get into Android development, and being able to list an actual project on my resume seems likely to be beneficial. However, the application itself is far more useful on a PC than a tablet and almost useless on a smartphone; odds are, very few (if any) people would want to use this on Android.

I want to develop it, but I anticipate almost no demand. Should I do so under the idea that the experience is useful, or should I either keep it private or not do it under the idea that an app nobody uses looks bad to future employers?

Original Question:

I'm planning out an open-source project, mostly to beef up my resume (ETA: Okay, I'm doin it mostly because I want to do it, but I'm releasing it as open-source rather than keeping it to myself so I can list it on my resume easier). I'm considering doing an Android version, intended to run on tablets. But it's not the most useful thing to have on a tablet; neither I nor my partner can really conceive of anyone wanting the product. However, adding "developed for Android" to my resume seems to be a good selling point, and I'd like to get into mobile development. Should I make an app nobody wants so I can say I made an app? Or should I hold off until I have a better idea?

Edit: I must have phrased things badly, some of the answers seem to have the wrong idea. I'm doing the entire project for the hell of it; if I don't do an Android version of this particular project, I'll complete it sooner and plan something else and do that. It's a given that I'm always going to be doing a project and that I want to do this project. The question is, should I instead do something more useful as a "let's play with Android" project? Will making something nobody wants hurt me in the long run?

答:
I would recommend coding a project on Android that you are itching to develop, instead of making one to boost up your resume. When you are passionate about your work you learn the most, as it's when you are the least willing to give up on the hard mini-problems within a project. Almost all great programmers have hundreds (often never published) projects under their belt, from when they can't help the need to try something out. These are the programmers companies love to hire, as they are more "true" to the art.

Now, those hundreds of projects are hobbyist projects, and the next step is to showcase professional experience. You want to show that you can not only code on some platform, but you can also finish a project too. You want to show that you are smart and get things done: http://www.joelonsoftware.com/articles/GuerrillaInterviewing3.html

(EDIT: I guess there's a book on it here too: http://www.joelonsoftware.com/items/2007/06/05.html)

So, to be clear, I'm not saying you should hold off until you have a better idea, either. As action generates inspiration. Don't wait for inspiration to generate action.

What you do with this seemingly conflicting advice is up to you, but I hope it helps.


答:
Can you already do stuff for Android? If yes, then just add that to your resume and use your time to learn something else. If not, then doing any kind of app for Android is a learning opportunity. Getting into mobile development business is probably easier when you can do mobile development. Being able to say that you can is just a side effect.

Will making something nobody wants hurt me in the long run?

90 % of everything is crap. When it comes to Android software, I think the number is closer to 99 %. So you're not alone in making something nobody wants. The company behind Angry Birds made (if I recall correctly) 51 games that almost nobody wanted before hitting the goldmine. The trouble is, you'll never know in advance...

Title: Should I develop a product with minimal use so I can say I developed it?

Body:
I appear to have done something wrong here, so let me try to rephrase this more simply so I stop giving the wrong impression.

I'm in the planning stages of a project right now, on my own time; I'm currently defining the scope of the project. I can see this application also releasing an Android app; furthermore, I've long wanted to get into Android development, and being able to list an actual project on my resume seems likely to be beneficial. However, the application itself is far more useful on a PC than a tablet and almost useless on a smartphone; odds are, very few (if any) people would want to use this on Android.

I want to develop it, but I anticipate almost no demand. Should I do so under the idea that the experience is useful, or should I either keep it private or not do it under the idea that an app nobody uses looks bad to future employers?

Original Question:

I'm planning out an open-source project, mostly to beef up my resume (ETA: Okay, I'm doin it mostly because I want to do it, but I'm releasing it as open-source rather than keeping it to myself so I can list it on my resume easier). I'm considering doing an Android version, intended to run on tablets. But it's not the most useful thing to have on a tablet; neither I nor my partner can really conceive of anyone wanting the product. However, adding "developed for Android" to my resume seems to be a good selling point, and I'd like to get into mobile development. Should I make an app nobody wants so I can say I made an app? Or should I hold off until I have a better idea?

Edit: I must have phrased things badly, some of the answers seem to have the wrong idea. I'm doing the entire project for the hell of it; if I don't do an Android version of this particular project, I'll complete it sooner and plan something else and do that. It's a given that I'm always going to be doing a project and that I want to do this project. The question is, should I instead do something more useful as a "let's play with Android" project? Will making something nobody wants hurt me in the long run?


答:
If you're doing it to beef up your resume you're making a mistake.

Do it because you want to learn, do it because you think it will be fun, do it because you want to get into mobile development and the best way to do that is to develop for mobiles.

If, having done that (i.e. produced a non-trivial mobile application), you still want to go play in that area then you can choose to add the app to the resume - doesn't really matter how generically useful it is (though if its not useful why publish?) so long as you can use it to illustrate your capabilities - to which end "Hello World!" probably won't get you very far.

And remember, above all else, you have to assume that you will be found out, sooner or later, if you are not reasonably honest about your capabilities.


答:
I'm planning out an open-source project, mostly to beef up my resume.

That's a valid reason, but it may backfire. If your only motivation is to beef up your resume, there's high chance the end result will be poor. A potential employer may check your developed for Android claim, and if the only thing to support it it's a poorly designed and/or coded application, you won't get hired.

However, adding "developed for Android" to my resume seems to be a good selling point, and I'd like to get into mobile development.

Employers actively looking for Android developers, will probably not consider you if you've only build one minor application, regardless if it's a poor one or not.

But you should go ahead and do it anyway, provided that the time you spend on the application couldn't be better spent elsewhere. One is better than none, and there is a small possibility all of the above will be overlooked by a potential employer.

It would be better if you did it for the fun of it, or for educative purposes, and you went for something that's actually useful, but in practice it's better if you build it for all the wrong reasons than not build it at all, as you will at least learn the basics of Android development.


答: chances are you are never going to come up with an idea for an app that any large group of people would be interested in, but you are never going to make an app everyone wants if you don't know how to make a decent app. you should make lots of apps not just one, make all kinds of apps, copy existing popular apps, make useless apps, none of these have to be released, but you need to make a ton of apps so if you ever do get an idea for a good app you are capable of actually developing that app. just making an app to say you can make apps on your resume without flat out lying is a terrible idea.</p>


答:
Do it ! Consider it as an academic experience :

You will do a theoric experiment that will not have a direct and obvious use, but will help improve your skill at one technology.

Making it open source allows it to be easily peer-reviewed. You will be able to seek reviews and be teached to improve yourself.

Even if it's now a theoric experiment, you or someone else may rework your idea and transform it in something useful.

Put enough energy to make it a valuable item in your portfolio. Once you're done, iterate either by improving this project (You'll certainly get ideas while developing it) or create another one.


问:
Reasonable to use different version controls for different parts of a web application?
I am contemplating a few different techniques for organizing code for a larger web application. For this situation, the server runs some Microsoft solution (probably ASP.NET MVC or OpenRasta) and the client (JavaScript, CSS, etc.) will consume this. Traditionally in an MVC application, the controllers and models along with the client codebase all live in the same project/solution. Our current solutions use TFS for source control.

I want to start using Sass and Compass for the front-end, which will require Ruby, and I would like to use git for the version control of the front-end and continue to use TFS for the server components. The problem I have is that in order for someone to run the solution, you would need to pull from both repositories, and I am not sure if that is reasonable.

Would you attempt something like this? Can you think of a better way for the projects to be structured so that front-end is separated from back-end? If I have not explained this well enough I will be happy to elaborate.

答:
I would discourage this practice, and encourage a single unified version control (and larger configuration management) policy on a per-project basis.

Any individual, at any point in time, should be easily able to recreate the project as it was in a particular moment of time, and splitting the project up into multiple version control systems makes this much more difficult, since you are dealing with commits, branching, and tagging in two systems instead of one.

As far as separating the back-end from the front-end, a logical separation is fine, and doesn't require a separation in version control. If you are reusing the same components across multiple projects, consider a trunk and creating appropriate branches for specific changes that might be on a per-project or per-client basis.


答:
I don't entirely agree with maple_shaft's answer, but there wasn't enough room in the comment to say my entire bit! ;-)

I agree that every developer can and should be an architect, but that does not mean that every developer should be responsible for the architecture of an entire product or system.  Further, I don't think you can paint every architectural team with the same broad brush, and when done right architectural teams can deliver great value to the overall product development process. The misconception is that the architects should dictate every aspect of the system design.  They should instead focus on the higher level design, and leave the implementation details to their development teams.  That isn't to say however that the developers shouldn't be involved in the planning and design process from the outset.

The larger and more modular and ultimately more complex a product is, the more likely you will find various parts of the product handled by different development teams.  Such teams need not understand the system as a whole provided they have a full understanding of the parts of the system that they are responsible for. Often these additional teams are brought on as subcontractors for the specific purpose of developing a module in a particular area of technology that the architects or other teams may not have expertise in. My own particular talents lie in developing API's, and I have yet to see a well factored API that was developed entirely organically without either being a complete mess in terms of usability, or that did not require someone to stand out as the person who ensured there was a level of uniformity between different aspects of the API. I can go on to list many examples and reasons, but I don't think that these sort of situations are the ivory tower BS that many might think they are.  Unfortunately, there are many places, particularly in areas of defense, medical, and the financial sectors where corporate paranoia does result in poorly specified and even more poorly managed product development of the sort that I'm sure maple_shaft was most concerned about. These are the things that I believe give architects a bit of a poorly deserved bad name (generally speaking).

So where is the middle ground that the OP was looking for?  The answer is all to do with opening channels of communication.  The architects need to hand over specifications that describe their designs in enough detail so as to ensure the development teams will understand where the boundaries are.  Stories and Feature Scenarios in the broadest sense, where everything is considered a black-box.  The architects then need to ensure that the teams have access to the architect's time to confirm any assumptions, and to have any questions answered about specifications that seem too broad, or unclear.  After that, it's really about ensuring that individual teams are made aware of what the other teams are working on, and that they know who to liaise with on the other teams to ensure each part of the system will play nicely with the other parts.  These teams meet each other directly.  Once the system has been designed at the broadest level, the architects should really just be the people the teams turn to when they need a sanity check, and to ensure that the product "vision" is maintained.  They should also take on board any integration process required, and provide much needed "air-cover" for the development teams from the managers, customers, and any other stake holders, while still ensuring these various people can all get together to work out between them how things should work.

IMHO architects should first and foremost be facilitators & communicators, and designers second. As to what level of specification?  I think that the best architects are the ones who ask their teams about the level of detail that a team wants, and between them find a balance that works.  Different teams may have different requirements in terms of the amount of documentation or direction required.  Senior teams may find a roughly drawn diagram and a quick chat may be enough to get going with, while teams filled with relatively junior developers may require a little more to get them going.  Above all, the architect needs to encourage developers to exercise their own design talents in order to get the best end result from each team.

Title: Are there any best practices regarding the handover from architecture to development?

Body:
We are looking at improving the process for handing over tasks from architecture to development.

At one end of the scale it there is no architecture guidance you risk getting chaos, with each developer doing things his way.

At the other end of the scale where everything is specified, the specification takes longer than the development, and you risk having very boring development tasks.

Has anyone found an optimal middle ground between these extremes? Which artifacts do you deliver to development? For example: modules, class structure, or sequence diagrams?


问:
C++ and system exceptions
Why standard C++ doesn't respect system (foreign or hardware) exceptions?

E.g. when null pointer dereference occurs, stack isn't unwound, destructors aren't called, and RAII doesn't work.

The common advice is "to use system API". But on certain systems, specifically Win32, this doesn't work. To enable stack unwinding for this C++ code

```<code>// class Foo;
// void bar(const Foo&);
bar(Foo(1, 2));
</code>```

one should generate something like this C code

```<code>Foo tempFoo;
Foo_ctor(&tempFoo);
__try {
    bar(&tempFoo);
}
__finally {
    Foo_dtor(&tempFoo);
}
Foo_dtor(&tempFoo);
</code>```

and it's impossible to implement this as C++ library.

Upd:
Standard doesn't forbid handling system exceptions. But it seems that popular compilers like g++ doesn't respect system exceptions on any platforms just because standard doesn't require this.

The only thing that I want - is to use RAII to make code readable and program reliable. I don't want to put hand-crafted try\finally around every call to unknown code. For example in this reusable code, AbstractA::foo is such unknown code:

```<code>void func(AbstractA* a, AbstractB* b) {
    TempFile file;
    a->foo(b, file);
}
</code>```

Maybe one will pass to func such implementation of AbstractA, which every Friday will not check if b is NULL, so access violation will happen, application will terminate and temporary file will not be deleted. How many months uses will suffer because of this issue, until either author of func or author of AbstractA will do something with it?

Related: Is `catch(...) { throw; }` a bad practice?

答:
The C++ standard doesn't respect system exceptions because it was designed to be usable on a wide range of platforms (much wider that PC-based platforms). It would be impossible to provide some sort of support for each of the platform in the standard. This is left for implementations and rightfully so.

My reaction to the rant part of your question: Win32 exceptions are thrown in fatal cases from which you can't really recover. __try & friends does work in C++ as well (not only for C), and you can manually call the destructor if you need to (but your program is in a state where it won't run anymore, so unless that destructor releases something the OS wouldn't normally release after the process terminated, there isn't much point).

Edit: In answer to your update: You are still ranting. It's not how you imagined it, so what? You can still protect yourself against the scenario you cited as an example. You use the platform-specific code to catch the system exception, close the file and crash gracefully. There might be a better way to do this; ask a specific question on SO. Isolating 3rd party code is not trivial and likely requires some effort to achieve (a good example of this is the famously unstable flash plugin which now runs isolated in most major browsers).

g++ doesn't respect system exceptions on any platforms just because standard doesn't require this

Even though it does implement a good number of extensions, gcc targets architectures, not platforms. Gcc itself is ported to different platforms but that's a different story; the code-generation part is architecture-dependent, not platform-dependent. This explains why it wouldn't be possible to support windows system exceptions without great effort.

Title: C++ and system exceptions


问:
When can you call yourself good at language X?
This goes back to a conversation I've had with my girlfriend. I tried to tell her that I simply don't feel adequate enough in my programming language (C++) to call myself good. She then asked me, "Well, when do you consider yourself good enough?"

That's an interesting question. I didn't know what to tell her. So I'm asking you.

For any programming language, framework or the like, when do you reach a point were you sit back, look at what you've done and say, "Hey, I'm actually pretty good at this."? How do you define "good" so that you can tell others, honestly, "Yeah, I'm good at X".

Additionally, do you reach these conclusions by comparing what others can do?

Additional Info

I have read the canonical paper on how it takes ten-thousand hours before you are an expert on the field. (Props to anybody that knows what this paper is called again)

I have also read various articles from Coding Horror about interviewing people. Some people, it was said, "Cannot function outside of a framework." So they may be "good" for that framework, but not otherwise in the language. Is this true?

答:
One is good at something only when they can confidently and correctly say they can do it.

If you want to say you're good at C++, for example, you ought to be able to say, with confidence and justification, that given a general problem using C++, you can solve it.

This provides a distinction from being cocky, which would be to confidently say you can do something without sufficient justification; and experienced, which would be to say you can do something because you have done it in the past.

ContentLicense: CC BY-SA 2.5


问:
Best practice in setting return value (use else or?)
Whenever you want to return a value from a method, but whatever you return depends on some other value, you typically use branching:

```<code>int calculateSomething() {
  if (a == b) {
    return x;
  } else {
    return y;
  }
}
</code>```

Another way to write this is:

```<code>int calculateSomething() {
  if (a == b) {
    return x;
  }
  return y;
}
</code>```

Is there any reason to avoid one or the other? Both allow adding "else if"-clauses without problems. Both typically generate compiler errors if you add anything at the bottom.

Note: I couldn't find any duplicates, although multiple questions exist about whether the accompanying curly braces should be on their own line. So let's not get into that.

答:
There is no point to use else after return.

LLVM Coding Standards says the same:

...do not use 'else' or 'else if' after something that interrupts control flow — like return, break, continue, goto, etc. For example, this is bad:

```<code>case 'J': {
  if (Signed) {
    Type = Context.getsigjmp_bufType();
    if (Type.isNull()) {
      Error = ASTContext::GE_Missing_sigjmp_buf;
      return QualType();
    } else {
      break;
    }
  } else {
    Type = Context.getjmp_bufType();
    if (Type.isNull()) {
      Error = ASTContext::GE_Missing_jmp_buf;
      return QualType();
    } else {
      break;
    }
  }
}
</code>```

...The idea is to reduce indentation and the amount of code you have to keep track of when reading the code.

Body:
There is no point to use else after return.

LLVM Coding Standards says the same:

...do not use 'else' or 'else if' after something that interrupts control flow — like return, break, continue, goto, etc. For example, this is bad:

case 'J': {
  if (Signed) {
    Type = Context.getsigjmp_bufType();
    if (Type.isNull()) {
      Error = ASTContext::GE_Missing_sigjmp_buf;
      return QualType();
    } else {
      break;
    }
  } else {
    Type = Context.getjmp_bufType();
    if (Type.isNull()) {
      Error = ASTContext::GE_Missing_jmp_buf;
      return QualType();
    } else {
      break;
    }
  }
}

...The idea is to reduce indentation and the amount of code you have to keep track of when reading the code.


答:
You can configure MSVC to catch system exceptions in a catch(...) block. This is exactly as the Standard intended- implementations provide mechanisms to catch errors thrown by their implementations. Strictly speaking, it's just UB and they don't have to provide any mechanism.

However, there's an increasing trend, both within and outside Microsoft, to not defensively code- for example IsBadXXXPtR is now heavily discouraged.

Title: C++ and system exceptions

Body:
Why standard C++ doesn't respect system (foreign or hardware) exceptions?

E.g. when null pointer dereference occurs, stack isn't unwound, destructors aren't called, and RAII doesn't work.

The common advice is "to use system API". But on certain systems, specifically Win32, this doesn't work. To enable stack unwinding for this C++ code

```<code>// class Foo;
// void bar(const Foo&);
bar(Foo(1, 2));
</code>```

one should generate something like this C code

```<code>Foo tempFoo;
Foo_ctor(&tempFoo);
__try {
    bar(&tempFoo);
}
__finally {
    Foo_dtor(&tempFoo);
}
Foo_dtor(&tempFoo);
</code>```

and it's impossible to implement this as C++ library.

Upd:
Standard doesn't forbid handling system exceptions. But it seems that popular compilers like g++ doesn't respect system exceptions on any platforms just because standard doesn't require this.

The only thing that I want - is to use RAII to make code readable and program reliable. I don't want to put hand-crafted try\finally around every call to unknown code. For example in this reusable code, AbstractA::foo is such unknown code:

```<code>void func(AbstractA* a, AbstractB* b) {
    TempFile file;
    a->foo(b, file);
}
</code>```

Maybe one will pass to func such implementation of AbstractA, which every Friday will not check if b is NULL, so access violation will happen, application will terminate and temporary file will not be deleted. How many months uses will suffer because of this issue, until either author of func or author of AbstractA will do something with it?

Related: Is `catch(...) { throw; }` a bad practice?

ContentLicense: CC BY-SA 4.0


答:
IMO using different VCS at the same time just give you a headache from the maintenance standpoint. And also will make life of developers harder.

If your project histories are really separate from each other (different teams, branches, development cycle, etc.) I suggest to try to implement mechanism like svn externals or git submodules (TFS should have something similar). This approach worked well for us. Back-end developers are not concerned with UI and use their own tools. Main project tree has their branch defined as external, and front-end developers need not think too much about different dependencies when building their stuff.

Title: Reasonable to use different version controls for different parts of a web application?

Body:
I am contemplating a few different techniques for organizing code for a larger web application. For this situation, the server runs some Microsoft solution (probably ASP.NET MVC or OpenRasta) and the client (JavaScript, CSS, etc.) will consume this. Traditionally in an MVC application, the controllers and models along with the client codebase all live in the same project/solution. Our current solutions use TFS for source control.

I want to start using Sass and Compass for the front-end, which will require Ruby, and I would like to use git for the version control of the front-end and continue to use TFS for the server components. The problem I have is that in order for someone to run the solution, you would need to pull from both repositories, and I am not sure if that is reasonable.

Would you attempt something like this? Can you think of a better way for the projects to be structured so that front-end is separated from back-end? If I have not explained this well enough I will be happy to elaborate.


问:
How to estimate the length of a project based on another project?
I was wondering whether there were any estimating models for projects which use the results of previous projects.

For example, imagine I want to develop an application for a phone based on a web app I completed last month. Say the web app took 1000 hours but that I don't know anything about mobile development. If you wanted to add another number into the equation you could say that 50% of the features implement in the web app will need to be implemented for the mobile app.

Where would I even start to form an estimate for the new project?

Thanks in advance.

答:
Project estimation is a skill (and a hard one at that). I suggest you do some research if you want to aquire it. (here is a thread full of good books)

For example, imagine I want to develop an application for a phone based on a web app I completed last month. Say the web app took 1000 hours but that I don't know anything about mobile development.

If you dont know anything about mobile development any estimate you give will be basically guesswork. The accuracy of the estimate is based on your knoledge of the platform (none in your case).

My suggestion would be to do some prototyping first so you get a feel for the platform and can give them a ballpark estimate.


答: Dont take the webapp effort as basis for estimations of the mobile app. Though you maybe just do the webapp on mobile, you are developing a complete different application in technical Terms. I mean native development, no PhoneGap/HTML5 stuff. </p>

Title: How to estimate the length of a project based on another project?

Body:
I was wondering whether there were any estimating models for projects which use the results of previous projects.

For example, imagine I want to develop an application for a phone based on a web app I completed last month. Say the web app took 1000 hours but that I don't know anything about mobile development. If you wanted to add another number into the equation you could say that 50% of the features implement in the web app will need to be implemented for the mobile app.

Where would I even start to form an estimate for the new project?

Thanks in advance.


答:
There are indeed estimation models for projects, and in general they will definitely benefit from the results of previous projects.

However, the more unknowns in the project, the more difficult the estimation becomes.

In this specific case, the killer would be "don't know anything about mobile development".

If you were to redevelop your existing web app for a more limited mobile-web platform, your existing project experience would stand you in good stead.

However, it sounds as if you are going to create an actual mobile app?  If so, then the previous experience in this case is not quite worth nothing, but it is not worth very much.  Adding a feature to a web app can be quite different than adding it to an actual mobile app.  Some things are much simpler, and some things are much harder.

If you are stuck on getting some kind of estimate, then my suggestion would be to find a mobile-app expert.  Discussing/designing closely with someone who has that expertise should give you some of the answers you are looking for with respect to the overall (re)development time.


问:
Dynamically vs Statically typed languages studies
Do there exist studies done on the effectiveness of statically vs dynamically typed languages?

In particular:

Measurements of programmer productivity

Defect Rate

Also including the effects of whether or not unit testing is employed.

I've seen lots of discussion of the merits of either side but I'm wondering whether anyone has done a study on it.

答:
Some suggested reading:

Developers Shift to Dynamic Languages (PDF)

On the Revival of Dynamic Languages (PDF)

Static typing where possible, dynamic typing when needed: The end of the cold war between programming languages (PDF)

The Security of Static Typing with Dynamic Linking (PDF)

Combining Static and Dynamic Reasoning for Bug Detection (PDF)

Dynamic Typing in a Statically Typed Language (PDF)

Turning Dynamic Typing into Static Typing by Program Specialization (PDF)

Hybrid Type Checking (PDF)

Not exactly on static typing, but related:

Securing web application code by static analysis and runtime protection (PDF)

Some interesting articles or essays on the subject or on static analysis of programs in general:

Pluggable Type Systems (PDF)

Strong Typing vs Strong Testing

Linux Kernel Developer Responses to Static Analysis Bug Reports (PDF)

Is Weak Typing Strong Enough?

Correlation Exploitation in Error Ranking

Improving Software Quality w/ Static Analysis

And for the ones who would be wondering what this is all about:

Introduction to Static and Dynamic Typing

However, I doubt any of these with give you a direct answer, as they don't do exactly the study you're looking for. They will be interesting reads though.

Personally, I firmly consider that static typing over dynamic typing facilitates bug detection. I spend way too much type looking for typos and minor mistakes like these into JavaScript or even Ruby code. And when it comes to the view that Dynamic Typing gives you a boost in productivity, I think that mostly comes down to tooling. If statically typed languages have the right tools to allow for background recompilation and provide an REPL interface, then you get the benefits of both worlds. Scala provides this for instance, which makes it very easy to learn and prototype away in the interactive console, but gives you the benefits of static typing (and of a stronger type system than a lot of other languages, ML-languages aside). Similarly, I don't think I have a loss of productivity by using Java or C++ (because of the static typing), as long as I use an IDE that helps me along. When I revert to coding only with simple configurations (editor + compiler/interpreter), then it feels more cumbersome and dynamic languages seem easier to use. But you still hunt for bugs. I guess people would say that the tooling issue is a reversible argument, as if tooling were better for dynamic languages, then most bugs and typos would be pointed out at coding-time, but that reflects the flaw in the system in my opinion. Still, I usually prototype in JRuby and will code in Java later most of the things I do.

WARNING: Some of these links are unreliable, and some go through portals of various computing societies using fee-based accesses for members. Sorry about that, I tried to find multiple links for each of these but it's not as good as I'd like it to be.


答:
Your company may have a dedicated IP department or specialist. Check with them. Your manager should be able to put you in touch.

Certainly it's ethical; I can't imagine your company would be sorry to have more access to your work and brain-power. You want to protect yourself from losing control over your own code. Some things you might consider doing first are to create an open-source project with your code in it, and assign it a license which is compatible with your company's IP policies.

Also, look into getting official permission to release any code you contribute to it. Some (many?) companies are fine with releasing code under open-source licenses so long as there is a clear separation between the open code and the company code. This may be true even if your contract says "we own everything you do even remotely related to work". In my experience, they're mostly worried about diluting their competitive advantage in their core business. This is another reason to package your code in a suitably licensed library instead of importing it directly.

Hope this helps.

Title: Is it ethical to use personal code at work?

Body:
I am working on a side project at work where I find it beneficial to use some of my code that I have developed personally (outside of work) to speed my development. My side project is developing a C++ GUI application to let our power users run queries (built by me) against databases on several different platforms (DB2, Oracle, SQL Server and MySQL). In the past, I would usually just run these myself on request or build an Excel VBA application for them. Now that I have built several VBA applications for several different people, I find the need to build one central application that just reads in custom .sql files and executes against various databases.

The application that I am building is in C++ and uses an LGPL cross-platform GUI toolkit. However, I have a lot of code that in my own libraries that I have built over the years on leisure, non-work related projects. Is it okay to use this code at work, thus saving me (and the company) time? If so, can I port any bug fixes and enhancements back to my personal library? There seems to be a line that I do not know when I am going to cross it.

I just want to add that none of the personal code has anything to do with any business logic. They are just basic utility classes/wrappers.


答:
I absolutely agree with the previous poster, ethics is not really a problem here in my opinion, unless you contract forbids you from using non in house developed scripts/software then you might have an ethical issue.

Your issue is actually property rights.

And here there are several issues you need to think about.

What does your contract say about intellectual property ?

Does your company retain rights to things you create?

What license does your company use when developing code?

Is it compatible with your own licenses ?

These are questions you need to have answered before you develop any code, allow already developed code to go into your company's repositories or taking development back...


答:
Since you strive to improve something, then you have already sensed a problem in your process. The root cause for the specific situation might be the following: The developers cannot identify themselves with the architecture, because it was imposed on them by someone external. Handing over the architecture to the development will very likely not solve this root cause.

Make the architecture a part of the development team. Tear down the border between the architect and the developer. This ensures that the information will flow. If the development team participates at shaping the architecture they will not regard it as something alien. Infuse knowledge about architecture into the team. Teach them the driving factors behind the corporate architecture to avoid the chaos you mentioned. Involve developers when architectural decisions must be made to avoid the boredom you mentioned. A handover is then not required anymore and you have fulfilled your role as an architect in a development team.


问:
What's the worst programming book you've ever read?
What's the worst programming-related or technical book you've ever read? This can be any book which one way or another can be connected to programming, as long as it's not fiction.</p>

答: Head First C#. Shame to the Head First family IMO.


答:
As the other answers say, don't be afraid to develop something just because you believe no one will want it - this kind of thing is hard to predict in advance.

However, have you considered contributing to an existing project, rather than start your own?

Advantages:

You demonstrate to future employers that you are a team player and can work in an existing structure.

You demonstrate that you can understand an existing project, and add value to it.

If the project is reasonably well-known and reputed, just the fact that your contributions were accepted will serve as a sort of endorsement of your work.

And finally:

Established user base, so your contributions will actually be useful.

Of course, the drawback is that you will have to deal with the politics of the project, and need to live with decisions that you don't like. But if you pick a project with policies you like, you can minimize these problems.


答:
Where would I even start to form an estimate for the new project?

It doesn't much matter.  Seriously.

Effort can be shown to depend on lines of code.  Read Boehm's Software Engineering Economics for details.  Pretty much any other measure has no usable correlation with effort.

The joke is this: You don't know lines of code until you're done.

You can try to use other "features" to predict lines of code.  A commonly-used feature the "story points" for each user story, since that's something you often know at the beginning of a project.

However.  Personal productivity, tools in use, and organizational politics have more impact than lines of code.  The time to learn new technology, for example, is almost impossible to predict.  (Except to say that it takes years to become an expert at something.)

In short, it doesn't much matter if you use a previous project or not.  Predicting the future is really hard.


问:
How can I feel more confident about my programming skills?
Programming isn't alien to me. I first starting doing markup (HTML, now please don't laugh at me) when I was 12 and a little bit of BASIC when I was 13 (I knew much about Flowcharts, Pseudocodes at this point), but then I was admonished into Biology in high school and hence missed out on "real" programming knowledge of languages such as C, Java, etcetera. I took up CS for my UG B.E. (similar to BS, but way more theoretical). I learnt C & C++ (to a lesser extent) on my own (my prof was a total pain and the class was filled with code-jocks (who had already learnt it in school, and hence paid no attention to class and didn't let lesser mortals like me to pay any attention to class either)) and could whip up an awesome addition or multiplication program (ones which now even kinder-gardeners' whip up with way more finesse) and a piss-poor knowledge of Java (which has even grown rusty in recent times).

My main problem is that I've always felt inadequate and strangled by my limited programming skills and belittled by the code-jocks (believe me, I've come across this site ages ago, but could just now build up the courage to actually post a question) and have been at times even depressed over said inability. Most people say that Programming isn't necessarily about the language but the state of mind that the person has and the techniques they employ to solve problems/issues. I agree with such sentiments, but can I ever acquire such a "state of mind", and if such how should I approach "Programming/Coding", and if there are any set ways and steps one most go through to attain the "Zen of Coding". How do I do so? Also, it wouldn't hurt if some Saint wanted to mentor this downtrodden piece of $#!^.

P.S. I would forever be grateful to any person who considers me worth their time, and as a bonus would name my first piece of Software I ship after them. (If I ever get to ship one, i.e.,)

TL;DR: Never really learnt "Programming/Coding", can't solve problems even if I try to. Help me!

答:
You will never feel confident about your programming skills.

The way you describe your skills, points to a mindset where you will be never satisfied with your skills. You mastered C++? Wait there is Java! You mastered Java? Wait there is Parallel Programming. You mastered Parallel Programming in C++ and Java? Wait there is SOA! There is OOD! And MVC! SOLID! Functional Programming! Web Programming! Cloud Programming! Mobile Programming!

The point is not to feel depressed because of this. You need to push some buttons in your head: Your doubt about your skills is pure fuel. You will likely never reach some satisfying level of programming skills. As long this is the case, you will move forward. The hard part is to realize it and do something against it, although there will be never a goal. The longer you can bear it the higher your skill level will be.

OwnerDisplayName: Ameen


问:
What's your strongest opinion against functional programming?
Functional programming is one of the oldest programming paradigms. However it isn't used much in the industry compared to more popular paradigms. But it have largely been emphasized in academia.

What's your strongest opinion against functional programming?

答:
I am a big fan and advocate of functional programming. But here are my points:

easy to learn

Programming languages like python and ruby (and many other languages) are easy to learn. Advanced functional programming, with languages like Haskell, Agda, Coq, ATS, etc., is quite hard to learn. Some use the term “mathematical structured programming”. It’s easy if you are familiar with category theory and abstract mathematics, but quite some work if you have no clue what for instance "monads" are.

programming with a scripting language can mean more productivity.

In some situations using scripting languages like python and ruby can lead to more productivity. This means fast prototyping and gluing together different packages or libraries. Even using dynamic languages (e.g. dynamic object oriented programming) can be a good thing in this context. Usually static typing is better, but scripting with dynamic types can have a positive effect.

business considerations

Programming is only a small subset of successful software projects. Software has to work, users have to be happy and this is don't necessarily depend on the programming language used. Managers have to think of the benefits and risk when evaluating new technology and programming languages. Can new programmers learn quickly the new programming language? Is there experience in the company with the technology? Is there a risk and will this be hard to argue with upper management?

In the business context, functional programming can be used in systems that add to the core software components,e.g., components that are not so mission critical. For example a bank that will hardly change the core software, but add new parts (GUI, monitoring software, etc.) in new programming language. (Maybe there are exceptions, but this is my experience with banks.)

Further, functional programming is very useful when formal verification is a benefit or a must.


答:
In development it seems that the paradox "the more you know, the more you know you don't know" holds true.

If you are a thoughtful, honest person, you will need to accept this fact and learn to deal with it.

Confidence, in the sense implied by the question, is a very personal thing that really has nothing to do with a particular skill set or methodology.

On a more shallow note, the sentiment described in http://www.kalzumeus.com/2011/10/28/dont-call-yourself-a-programmer/ (section: You radically overestimate the average skill of the competition because of the crowd you hang around with) has always helped me.

I would suggest that you learn to be more confident in the work that you have done as opposed to building confidence in your skills as a whole. The single best way to do this is to write repeatable tests for all of your code. It will work wonders on your psyche.

Title: How can I feel more confident about my programming skills?

Body:
Programming isn't alien to me. I first starting doing markup (HTML, now please don't laugh at me) when I was 12 and a little bit of BASIC when I was 13 (I knew much about Flowcharts, Pseudocodes at this point), but then I was admonished into Biology in high school and hence missed out on "real" programming knowledge of languages such as C, Java, etcetera. I took up CS for my UG B.E. (similar to BS, but way more theoretical). I learnt C & C++ (to a lesser extent) on my own (my prof was a total pain and the class was filled with code-jocks (who had already learnt it in school, and hence paid no attention to class and didn't let lesser mortals like me to pay any attention to class either)) and could whip up an awesome addition or multiplication program (ones which now even kinder-gardeners' whip up with way more finesse) and a piss-poor knowledge of Java (which has even grown rusty in recent times).

My main problem is that I've always felt inadequate and strangled by my limited programming skills and belittled by the code-jocks (believe me, I've come across this site ages ago, but could just now build up the courage to actually post a question) and have been at times even depressed over said inability. Most people say that Programming isn't necessarily about the language but the state of mind that the person has and the techniques they employ to solve problems/issues. I agree with such sentiments, but can I ever acquire such a "state of mind", and if such how should I approach "Programming/Coding", and if there are any set ways and steps one most go through to attain the "Zen of Coding". How do I do so? Also, it wouldn't hurt if some Saint wanted to mentor this downtrodden piece of $#!^.

P.S. I would forever be grateful to any person who considers me worth their time, and as a bonus would name my first piece of Software I ship after them. (If I ever get to ship one, i.e.,)

TL;DR: Never really learnt "Programming/Coding", can't solve problems even if I try to. Help me!


问:
Programming "everything" using HTML5?
HTML 5 applications in the browser really seem to be taking off. I've been using src:kit within Google Chrome for a few weeks and love it. I'm an ASP.Net (C#/MVC 3) developer by trade, and in the past did several pieces of WebForms programming.

With Windows 8 app development moving into the trade of local HTML5 apps, and the major smartphone browsers supporting HTML5 installation, as well as many platforms supporting it (PhoneGap and Titanium, for example), are we already/will we soon be at the point that I could create an app that would be fully "installable" to run as a standalone on every platform?

I do realise that a database (or instert-your-data-store-here) would also be necessary, so adding another language in there for middleware would be necessary. C# on Mac/Linux with Mono is possible, but Mono generally only creates a GTK+ Application, so I would likely need to create another wrapper to house the application... I think.

Any suggestions of a better language to use as middleware? I.e. for ease of transportation - I've got far more experience with C# than anything else so would like something from that family if I'll need to do something different.

Basically, how far away are we from this? What still needs to change? Most importantly, if it is possible (which I believe, theoretically it is), what is the big jump between where we are now and when we will be there?

This will eventually turn into a program, so it is a completely practical problem that I'm working my way through (I'll start development after Christmas).

EDIT: To clarify, by 'every' platform, I include at least the following: Windows XP+/Mac OS X/Linux: any distro pretty much in the last 2 years/iOS/Android/Blackberry 5+/Windows Phone 7+

答:
I would think that for back end services (db) you just need a RESTful web services implementation.  That should be something you could implement in just about any language on any platform.  Some platforms/frameworks will get you there faster obviously.  I am not a C# developer so I don't know how difficult it is to do that in C#, but I would think the necessary pieces are there.

There are also some emerging technologies that will securely connect from the browser (HTML5) application to the db, but that does seem a tad risky.  Maybe others can comment on the availability of those platforms and how secure they are.

Title: Programming "everything" using HTML5?


答:
Confidence is not something you should try to feel about your skills.  Confidence is poorly (likely even negatively) correlated with actual skill.  You should be working to improve your professional (or valued hobby) skill set no matter what you feel about your current skill level.

Confidence is something that other people, those whom you think are competent, should come to feel about your skills after working with you or seeing your work.


答:
I know this will not be very popular but the comment you made

At the other end of the scale if everything is specified, the specification takes longer than the development. And you risk having very boring development tasks.

is actually something you should strive for.  If the design and specification is solid enough that the development tasks are boring, then the cost of development goes down.  It is much less expensive to fix a specification than it is to fix code, and the biggest cost of software projects is not the build, it is the long term support.  And supporting code that is based on a solid spec is much less expensive.


问:
The value of an updated specification
I'm at the tail end of a large project (around 5 months of my time, > 60,000 lines of code) on which I was the only developer.  The specification documents for the project were designed well early on, but as always happens during development, some things have changed.  For example:

Bugs were discovered and fixed in ways that don't correspond well with the spec

Additional needs were discovered and dealt with

We found areas where the spec hadn't thought far enough ahead and had to change some implementation

Etc.

Through all this, the spec was not kept updated, because we were lean on resources (I know that's a questionable excuse).  I'm hoping to get the spec updated soon when we have time, but it's a matter of convincing management to spend the effort.  I believe it's a good idea, but I need some good reasoning; I can't speak from very much experience because I'm only a year and a half out of school.

So here are my questions:

What value is there in keeping an updated spec?

How often should the spec be updated?  With every change made that might affect it, just at the end of development, or something in between?

EDIT to clarify: this project was internal, so no external client was involved.  It's our product.

答:
I believe the most important thing that an "as-implemented" spec should cover is the reasons for the decisions that you made. Everything else should be obvious from the code and the tests (I hope half of those 60K LOC are tests!). In other words, the "what" and "how" are already expressed in the code, which is the most up-to-date "document" that exists.

People who read your code later (including you) will wonder "why" you did things a certain way and that's not something the code or tests can answer. Questions from the low-level "why did you use a LinkedList instead of an ArrayList" to the high-level "why did you use framework X instead of Y or Z?" are important to discuss in an document that's written after you've implemented things in code. There's nothing worse than encountering some code that does things a certain way, changing it to some other mechanism, and finding out your new way doesn't work and then finding out that your "new" way had already been tried and discarded! If only someone had told you...

As for how often should it be updated, my rule-of-thumb is whenever a non-trivial decision is made. If you wait until you've finished a feature, or portion of a feature, you'll probably forget some of the nuances that went into your decision to do things a certain way.

Title: The value of an updated specification


答:
Even though I have little experience with functional programming languages (I know some Haskell and Lisp) I find the FP paradigm very powerful and often more elegant than other paradigms. I wish I had the opportunity to work on a serious project using FP.

The only area in which I have some serious doubts regarding the effectiveness of FP is in how it can deal with complex data structures that cannot be defined inductively, e.g. graphs. For example, if I have to implement an algorithm that works on a large graph, possibly walking through the graph and making small local changes, I wonder if an FP approach can match an imperative approach in which the program is allowed to move from node to node using pointers.

Body:
Functional programming is one of the oldest programming paradigms. However it isn't used much in the industry compared to more popular paradigms. But it have largely been emphasized in academia.

What's your strongest opinion against functional programming?


答:
I used to feel the same way, and it was actually the Stack Exchange sites that helped give me confidence.

I started using StackOverflow to find answers for my questions, and one day I saw one I knew the answer to. I posted the answer, got some up-votes and a comment saying it was a good answer, and that encouraged me to look around for other questions I could answer.

It soon grew into an addiction for me, finding unanswered questions that I could solve, and as time went by I started gaining confidence in my answers. I no longer had to say "I think this is because...." or "This should cause..." but could instead say with some confidence that "This is because... " or "This causes..."

I like puzzles, and to me SO questions were like mini-programming puzzles, with the added benefit of getting some positive feedback if I got the answer right. If I got an answer wrong, I just deleted it and learned from other people's solutions to the same problem.

So my recommendation would be to go on SO and browse the questions in whatever tag you're interested in, and look for some you think you can find answers to. There's nothing quite like people telling you your programming answers are helpful/good to give you confidence in your programming ability :)


问:
How to parallelize a sequential algorithm?
What thought process should one follow to convert a sequential algorithm to a parallel one ?
Are there any specific code pattern that can be parallelized.
Some patterns that I normally use are:

Looking for loops that can parallelized.

Try to break algo in some form of Map-reduce format.

Looking for producer-consumer pattern.

答:
To somewhat formalize what you have already said about looking for loops that can be parallelized, the key concept being exploited is flat data parallelism. A majority of the parallel libraries (that I know of) seem to exhibit this (e.g. Microsoft Task Parallel library for .NET, Microsoft Parallel Patterns Library for C++)

Flat data parallelism happens when you have a chunk of (flat) data (e.g. an array) that you want to perform work on, you then divide up the data into chunks of how many processors you have, does independent work in parallel for each of those chunk, and finally potentially aggregate/combine the result of each chunk to get your final result.

A sample article on this:
http://goose.ycp.edu/~dhovemey/spring2011/cs365/lecture/lecture18.html

OwnerDisplayName: Saurabh Saxena

OwnerDisplayName: ryaner


答:
Ian Foster describes four basic steps in his book "Designing and Building Parallel Programs":

Partitioning - find possible ways to split the data among the workers as fine-grain as possible.

Communication - identify the communication patterns.

Agglomeration - reduce the initial partitions to coarse-grain tasks according to the resources available.

Mapping - map the tasks onto the processing units.

The book is free online, you can find it here: http://www.mcs.anl.gov/~itf/dbpp/text/book.html

Title: How to parallelize a sequential algorithm?

Body:
What thought process should one follow to convert a sequential algorithm to a parallel one ?
Are there any specific code pattern that can be parallelized.
Some patterns that I normally use are:

Looking for loops that can parallelized.

Try to break algo in some form of Map-reduce format.

Looking for producer-consumer pattern.


答:
Where would I even start to form an estimate for the new project?

You start by implementing one use case and see how long it takes.  Then you estimate a multiplier for the rest of the use cases, and extrapolate.


答:
Let's start with the process by which you estimate how long it takes to do your work. Always estimate time for documentation and meetings and email communications. Now for future projects you won't run out of time to do those things. Also assume only 6 hours per day per person when figuring out the end date for delivery (there is always indirect work such as required HR meetings and vacation, etc. to account for, you can never plan for anyone to be on a project 40 hours a week or you will miss every deadline and never have time to do documentation). These are the two most common reasons why I have seen people run out of time.

To my mind what is critical for you to update on this last project are the bugs you fixed that did not meet the spec. Personally your manager failed there as he should never have allowed that to happen, particularly if the customers (and internal users are also customers) were not informed beforehand.  There may be a good reason from a user perspective for that requirement that you threw out because it was easier to fix the bug if you ignored the requirement.  They may now be expecting behavior they are not going to get. That is a failure of your entire development staff that you allow such actions to happen.

One reason this needs updating is for maintenance. Sooner or later someone new will come along to fix something that was changed without documentation and will think that the failure to follow the spec was a bug, not a deliberate action and will change it back to follow the spec.

Or the users will complain that it doesn't do X which was in the spec and you won't have any proof that X was changed because Y bug caused X to be reevaluated as a requirement. Having been in a few of these argumnents in the past, I can tell you they aren't pretty whether they are internal or external customers. The less agreement you got for these changes before you did them, the more likely they are to rise up and bite your development staff later. And six months from now you won't remember why you did it that way either. It's no fun to explain why you did something when you have no idea why you did it.

Additional features aren't as critical, but should probably at least be listed even if you don't have the time to do a complete description.

You need to make these changes now when they are fresh. Convince your manager to let you spend a day or even half a day doing this. Or sneak in a half-hour every day for the next couple of weeks if you have to in order to document the most critical deviations.

Title: The value of an updated specification

Body:
I'm at the tail end of a large project (around 5 months of my time, > 60,000 lines of code) on which I was the only developer.  The specification documents for the project were designed well early on, but as always happens during development, some things have changed.  For example:

Bugs were discovered and fixed in ways that don't correspond well with the spec

Additional needs were discovered and dealt with

We found areas where the spec hadn't thought far enough ahead and had to change some implementation

Etc.

Through all this, the spec was not kept updated, because we were lean on resources (I know that's a questionable excuse).  I'm hoping to get the spec updated soon when we have time, but it's a matter of convincing management to spend the effort.  I believe it's a good idea, but I need some good reasoning; I can't speak from very much experience because I'm only a year and a half out of school.

So here are my questions:

What value is there in keeping an updated spec?

How often should the spec be updated?  With every change made that might affect it, just at the end of development, or something in between?

EDIT to clarify: this project was internal, so no external client was involved.  It's our product.


问:
Allowing the user to specify the location of a logfile
I'm working on an application, and adding logging, but now I'm stuck.

I want to allow (not force!) the user to set the location of the logfile.

Basically, my problem is:

logger initialization should be the first thing the program does

but I can't initialize the logger until I determine where the user wants the log to be saved

determining where the log should be saved ... is a process that should be logged

How is this problem solved?  Are log file locations not user-customizable?  Is log output buffered until a logfile is set?

答: Add the location of the log file as a value in a configuration file. That way the user can configure this value before they run your application and your application can simply read it from the configuration file. Include a default value in your configuration file in case the user does not modify the value.</p>


答:
The decision where to store the logfile should have to be made by you in the first place (to get things initialized). Then offer the user the possibility if he wants to change he could (but does not have to).

You wrote that you want the user to be able to set the location of the log file. You propably have your reasons to do so, but: Consider if you realy want every user to have to set the logfile location.

Title: Allowing the user to specify the location of a logfile

Body:
I'm working on an application, and adding logging, but now I'm stuck.

I want to allow (not force!) the user to set the location of the logfile.

Basically, my problem is:

logger initialization should be the first thing the program does

but I can't initialize the logger until I determine where the user wants the log to be saved

determining where the log should be saved ... is a process that should be logged

How is this problem solved?  Are log file locations not user-customizable?  Is log output buffered until a logfile is set?


答:
I seem to remember a quote from an author:

```<code>You should write a story that interests you and would want to read
That way, you will always find an audience
</code>```

I find the same applies to development (if you look at a lot of successful software out there): you should build something that you want to use, and you will probably find others will want to, as well.

Plus, it will be a learning experience, and will be a solid project to point to in resumes.

Body:
I seem to remember a quote from an author:

You should write a story that interests you and would want to read
That way, you will always find an audience

I find the same applies to development (if you look at a lot of successful software out there): you should build something that you want to use, and you will probably find others will want to, as well.

Plus, it will be a learning experience, and will be a solid project to point to in resumes.


问:
Explaining technical things to non-technical people
I often have to explain technical things and technical decisions to my extremely non technical manager and I'm pretty awful at it. What are good ways to essential dumb things down for the rest of the world who don't have a passion for programming?

Example questions I've been asked:

Why are you using Django instead of Java (Didn't accept that it was cheaper either)

Asking me to rephrase things in non technical words, my sentence was "Certain HTML tags are not allowed". How can I possibly dumb that down?

Other stuff that makes perfect sense to me, but is just so basic I don't know how to explain it

Why this, why that, why everything!

Also, how do I tell my manager to look the basic stuff up on Google, like "What is Pylons?"

答:
+1 for anyone talking about analogies, +1 for anyone talking about whiteboards or paper and pencil as visual aids.

Another trick I've learned, is that some people I've found if I write 5 pages about why something is, they will actually read it - I can tell, because a month later they'll say something and I know its from the document I wrote.

The odd thing is, I'm sure I had tried to explain the exact same thing verbally prior (even with visual aids and analogies) and they had not understood. I find this is especially helpful in political or emotionally charged situations or when frequent interruptions take things off course.

Do make sure to actually explain the problem however - and explain the why in terms of business benefit.  Once I explained the concept of technical debt to our CEO - and now, we can use this as conversational shorthand. "Why do you want to do this three day thing ? That web page looks fine to me!"  "It will remove technical debt, in that next time we have to fix it things will go much faster."  Then, the conversation can become about how much faster.


答:
Consider it a great opportunity to hone your presentation skills.

Consider it a great opportunity to review your technical fundamentals.

Speak in the language of the audience, NOT your language.

Investigate WHY the non-techie wants this information. What's the underlying reason? Is he bored? Curious to learn more? Wants to appear competent? Likes to drive you crazy? Super-extroverted with no one to talk to? Frustrated by your lack of progress despite your optimistic estimates (that's a common one!) ?

Title: Explaining technical things to non-technical people

Body:
I often have to explain technical things and technical decisions to my extremely non technical manager and I'm pretty awful at it. What are good ways to essential dumb things down for the rest of the world who don't have a passion for programming?

Example questions I've been asked:

Why are you using Django instead of Java (Didn't accept that it was cheaper either)

Asking me to rephrase things in non technical words, my sentence was "Certain HTML tags are not allowed". How can I possibly dumb that down?

Other stuff that makes perfect sense to me, but is just so basic I don't know how to explain it

Why this, why that, why everything!

Also, how do I tell my manager to look the basic stuff up on Google, like "What is Pylons?"


答:
Who is the log for?  If it's for you as a developer, don't let the user set it (ie: don't force them to think about something they don't care about).  If it is for the user to consult later, then put it in a default location and let the user change it later.

Whatever you do, do not, for the love of all that is holy, start your program with a dialog box "Where do you want your log file to go?" or require an environment variable $LOG_PLACE to be defined.  The only exception to this might be if your program's sole purpose in life was as a logger to something else.

Point is, be nice to your users, make the dang thing just work.  If someone cares to muck about and change a default you can let them, but make it work out of the box for the 99% of users who will never, ever, ever need to change where log file is saved at.


答:
(and by far the most important) The programmer workforce is not trained in those languages or styles

Many of the functional evangelists come off as a-holes or fruitcakes because of the way they try to sell functional.  No one likes an a-hole, and no one is going to throw money behind a fruitcake.  Mind you, I really like the functional stuff and would like to pull it in, but I know at my workplace I'd be the only person who could develop it without spending money on training (hard sell), and almost all of the good references talk-down at the reader.

Functional will come around when we have hundreds of cores and hit the realization that locks don't scale.  Then nested data parallel will be the only way to go for "big iron" programs, and functional excels at that.

Title: What's your strongest opinion against functional programming?


问:
Is it fine to have broken intermediate commits, as long as the final commit in any push works?
Related: Should every git commit leave the project in a working state?

Suppose I make the following commits locally:

Modify the database schema, breaking the application.

Update the application so it is compatible with the database schema again.

As long as I push both commits, master remains in a working state.  However, a historical version is broken.

I'm aware that I can use git rebase -i to squash the commits together.  However, the resulting commit will be large and less descriptive.  If I need to search the commit history to find out why I changed something, I'd rather find the original commit showing what I did and why.

My questions are:

Has anyone encountered difficulties due to broken historical commits in master?

If so, is there a simple way to avoid such difficulties, without discarding individual commit messages and changes?

答:
Largely depends on your outfit's branching strategy, but I think that having broken commits on development branches makes a ton of sense in general -- the real big "win" in using source control is to be able to roll back small changes and sometimes you are making a bunch of them and you gotta break eggs to make omlets.

The simple way to keep the individual commits without polluting master is to use branches. You can put the breaking/experimental stuff in there so you can have a fine-grained history without polluting the master branch's history.


答:
Broken commits are something that "just happens", shouldn't mean the end of the world. I do have a little nagging voice in the back of my head that tells me one shouldn't knowingly check in broken code, as a matter of principle and therefore including historical versions, however it's not something I'd go to war over.

Git's much praised branching model makes it feasible to keep broken commits off specific branches, e.g. if your team adopts gitflow or a simplified version thereof. Anything with a "clean master" policy. In this case, you could check in the final, working version as a merge commit, where the (broken) historical versions are available in the repository but off the main line.

If your team hasn't adopted such a branching model, then you have a valid excuse to just push the whole lot to master and be done with it.

Title: Is it fine to have broken intermediate commits, as long as the final commit in any push works?

Body:
Related: Should every git commit leave the project in a working state?

Suppose I make the following commits locally:

Modify the database schema, breaking the application.

Update the application so it is compatible with the database schema again.

As long as I push both commits, master remains in a working state.  However, a historical version is broken.

I'm aware that I can use git rebase -i to squash the commits together.  However, the resulting commit will be large and less descriptive.  If I need to search the commit history to find out why I changed something, I'd rather find the original commit showing what I did and why.

My questions are:

Has anyone encountered difficulties due to broken historical commits in master?

If so, is there a simple way to avoid such difficulties, without discarding individual commit messages and changes?


问:
Is CRTP used much? and why it is/isn't?
I'm thinking about curiously recurring template pattern.

I find it quite useful, and it's pretty well adjustable for many tasks. But I have to admit, I don't see much of CRTP code in the wild.

Is it hard to grasp? Are virtual functions easier overall? Shouldn't it be used for 90% of cases where virtual keyword appears?

答:
WTL uses the CRTP. Chromium browser is a well known example of software that uses WTL, so I'd say it's used "in the wild".

About the 90%? That's definitely an overstatement. Have you ever used a container of polymorphic objects? That's a very common usage of polymorphism and you can't do that with CRTP because Base<DerivedA> is not the same as Base<DerivedB>.

Title: Is CRTP used much? and why it is/isn't?


答:
Your brain doesn't like to work too hard. Given the choice, it prefers to take the easy way out. This is why it's easy to give up on things when you try to tackle something too ambitious - too much to learn, too many fiddly details to get right, too much yak shaving.

There are several things you can do to combat this. First off is energy. Try to do your practicing when you are well rested and well fed, or your brain literally won't have enough fuel for complex abstract thought. Second trick is interest or importance. If you can convince your brain that knowing maven is vital to escape the tiger chasing you, you will learn and retain more than when your brain thinks it is a meaningless side task on the way to what you really want. A third factor that is important is to stretch without overdoing it. Some effort will give you that buzz from achievement, and will help form new mental pathways, without being unachievable.

There is also something to be said for repeated practice. You want enough variation to be novel, but enough similarity that you get to exercise the same actions and ingrain them.

One further point is that you should attempt to roll up your sleeves and get your hands dirty. It is easy to spend a lot of time thinking about alternate approaches or the ideal solution, to the extent that you never get started. This is an example of your brain trying to take the easier way out. Try to recognize when this is happening to you and avoid it by trying to get started. Even a test or experiment is good. This also has the side benefit of making your brain want the closure of completing the task or finding the better solution.


答: I think as long as the commits are local and not pushed to others it's not only ok, it's actually a good way to work. Just don't push broken code to others. </p>


问:
How should I be keeping track of php script version/changes?
How should I be keeping track of a php script's versions/changes when it pertains to a single script in one file?

Should I have a separate changelog, and if so (1) what should it be named, (2) how should the contents of the log be formatted, and (3) how should the log be associated with the php script/file?

Or, should I include the changes in a comment at the top of the php file?  Currently, I have the following comments at the top of the file:

```<code>/**
 * @author    John Doe <contact@John Doe.com>
 * @version   1.0
 * @copyright Copyright (c) 2010, John Doe
 */
</code>```

Thanks in advance for your response!

答: Bro, use a versioning control system, svn, git, mercurial, even old CVS is better than nothing. And these are independent of whether you are using PHP or some other programming/scripting languages(s).</p>


问:
Should I develop a product with minimal use so I can say I developed it?
I appear to have done something wrong here, so let me try to rephrase this more simply so I stop giving the wrong impression.

I'm in the planning stages of a project right now, on my own time; I'm currently defining the scope of the project. I can see this application also releasing an Android app; furthermore, I've long wanted to get into Android development, and being able to list an actual project on my resume seems likely to be beneficial. However, the application itself is far more useful on a PC than a tablet and almost useless on a smartphone; odds are, very few (if any) people would want to use this on Android.

I want to develop it, but I anticipate almost no demand. Should I do so under the idea that the experience is useful, or should I either keep it private or not do it under the idea that an app nobody uses looks bad to future employers?

Original Question:

I'm planning out an open-source project, mostly to beef up my resume (ETA: Okay, I'm doin it mostly because I want to do it, but I'm releasing it as open-source rather than keeping it to myself so I can list it on my resume easier). I'm considering doing an Android version, intended to run on tablets. But it's not the most useful thing to have on a tablet; neither I nor my partner can really conceive of anyone wanting the product. However, adding "developed for Android" to my resume seems to be a good selling point, and I'd like to get into mobile development. Should I make an app nobody wants so I can say I made an app? Or should I hold off until I have a better idea?

Edit: I must have phrased things badly, some of the answers seem to have the wrong idea. I'm doing the entire project for the hell of it; if I don't do an Android version of this particular project, I'll complete it sooner and plan something else and do that. It's a given that I'm always going to be doing a project and that I want to do this project. The question is, should I instead do something more useful as a "let's play with Android" project? Will making something nobody wants hurt me in the long run?

答: Do it because you want to do it and expect to learn from doing so, and because the challenge fascinates you. Doing it for any other reason is a waste of time. </p>


答: I would go ahead and do it. Doing it for a resume is fine, but I think you'll get more out of it. This is much better than taking too much time trying to think up the next big thing. You may discover something useful along the way. It will benefit you when you attempt your next app.</p>


问:
Is there a such thing as a Program Manager for Outsourcing Companies?
Accordingly to the first paragraph of Joel's post, a Program Manager is a very good thing to have in products. But what about having a Program Manager for a company that doesn't have a product, but have projects?

The only coincidence that I'd see if you ask me and ask me to answer right away is that a Program Manager for an outsourcing company would be someone that oversees all the projects that the company have, ensuring that the things are being done aligned to the company strategy, from a technical point of view.

答: I'm confused by his terminology since my company calls the person who manages multiple projects from an account level as a program manager. Basically a project manager for project managers. The job he is describing is more universally known as an interaction designer as laid out by Alan Cooper. This type of role is most definitely used on project-based work. Anything that has a user interface needs this kind of design does by someone with experience if you want to ensure a decent level of quality.</p>

OwnerDisplayName: Sebastian


问:
What syntax element do you hate most in a programming language you use frequently?
No matter how much you love a programming language, there are always a few details in it that aren’t quite as nice as they could be.

In this question, I would like to specifically focus on syntax elements. In a programming language that you use frequently (perhaps your favourite programming language, or perhaps the one you are forced to use at work), which syntax element do you find most unreadable, unclear, inconvenient or unpleasant?

答:
Function pointer declaration syntax in C and C++:

```<code>(int)(*f)(int, int);
</code>```

That declares a function pointer named f whose pointee can take two ints and return an int.

I'd much prefer a syntax like this:

```<code>f: (int, int) => int
</code>```

Say you want to declare a function pointer g whose pointee can take two ints and a function from int and int to int, and return an int.

With C or C++ notation, you'd declare it as:

```<code>(int)(*g)(int, int, int(int, int));
</code>```

With the above-proposed notation same thing can be declared as:

```<code>g: (int, int, (int, int) => int) => int
</code>```

Latter is much more intuitive IMO.

Aside: The programming language called OOC fixes this syntax (and various other syntactical issues in C and C++). Check out its homepage here.

Body:
Function pointer declaration syntax in C and C++:

(int)(*f)(int, int);

That declares a function pointer named f whose pointee can take two ints and return an int.

I'd much prefer a syntax like this:

f: (int, int) => int

Say you want to declare a function pointer g whose pointee can take two ints and a function from int and int to int, and return an int.

With C or C++ notation, you'd declare it as:

(int)(*g)(int, int, int(int, int));

With the above-proposed notation same thing can be declared as:

g: (int, int, (int, int) => int) => int

Latter is much more intuitive IMO.

Aside: The programming language called OOC fixes this syntax (and various other syntactical issues in C and C++). Check out its homepage here.


问:
What are the important factors for database table design and object design?
When I do database table design, I often wonder if I should try to make the table as simple as possible, or if I should make the object as clear as possible.

The requirement is to store all month of the year's salesTon and gross profit.

I design from the object.The object has fields year, month, salesTon and gross profit. For this situation when I need save data to the database, it will save 12 rows(one row one month).  This object has a relationship with another object (customer). so when save it will save n(customer)*12 rows per one time. It will do a huge insert operation. I'm afraid that tihs will make the db slow.

Another design is to just use one object. One object to save the whole year - no need to split the object in to months. But in the object will has 12*2's fields like(month1_sales_ton, month1_gross_profit, month2_sales_ton, month2_gross_profit.......), this situation make save least rows, base on n(customer) per time.

But since the second situation doesn't have month, I can't write the common method when I want to search one year's one month gross profit which accept year, month parameters. Maybe I should just write the method to just pass year and get whole a year object? i don't know.

So which principle  should I follow when I design the table?

答:
You need to Normalize your data properly. You are not helping anybody with these summary tables. You are NOT Speeding anything up, YOU ARE NOT SAVING ANY DISK SPACE!*

I feel like a broken record saying this, but :

DO NOT MODEL YOUR DATA BASED ON HOW YOU WANT YOUR CODE TO CONSUME IT!

*You need to fully understand the rules of normalization before knowing when to break them (and you clearly don't). I can guarantee, in the long run, that de-normalizing will slow you down, take up more space, and inundate you with data integrity issues.

Oh Yea, The Most important thing when modeling your data is the actual Entity (and there data points) and how they relate to other Entities. This is why data models are generally synonymous with Entity relationship diagrams.