答:
HTML5 and Javascript all the way!

There are several 'game engines' using JS that you can download and play with. (Crafty, Impact, Melon JS, Akihabara) to name a few. Melon JS supports the 'Tiled tmx" format for platformers and top downs.

There is ongoing debate as to the 'web' technologies or native code question for mobile game / app dev and I think the concensus (and rule of thumb) is that if you need the hardware features of the physical device look towards naitive code. But if you don't need access to the hardware specific parts of the device, why not use a portible and web based solution? You will get more platforms with less effort.

As for Flash (and Silverlight) going the way of the Dodo bird, its not going be be an overnight abduction where you wake up tomorrow and they are just "gone"... There will be Flash games and site components around well after the technologies have been replaced. So there is no harm in learning flash, and will do nothing but help you as a developer, but for looking to the future of mobile games the answer is HTML5 and JS.

For an idea on what Adobe is doing, check out the Preview of Edge.

Hope that Helps.


问:
Finding header files
A C or C++ compiler looks for header files using a strict set of rules: relative to the directory of the including file (if "" was used), then along the specified and default include paths, fail if still not found.

An ancillary tool such as a code analyzer (which I'm currently working on) has different requirements: it may for a number of reasons not have the benefit of the setup performed by a complex build process, and have to make the best of what it is given. In other words, it may find a header file not present in the include paths it knows, and have to take its best shot at finding the file itself.

I'm currently thinking of using the following algorithm:

Start in the directory of the including file.

Is the header file found in the current directory or any subdirectory thereof? If so, done.

If we are at the root directory, the file doesn't seem to be present on this machine, so skip it. Otherwise move to the parent of the current directory and go to step 2.

Is this the best algorithm to use? In particular, does anyone know of any case where a different algorithm would work better?

答:
I think with any algorithm you won't succeed without knowing compiler command line used for particular file compilation. So, I see only two possibilities to use static analyzer with any build system:

"lint way" (which is probably not very well aligned with you requirements) place utility right before or instead of compiler invocation, passing all the same arguments. In this case you should dig into any build system/makefile to find all rules responsible for compilation.

"coverity way" run every build process under your tool, i.e. as a child/ren process(es). Thus, your tool should be clever enough to track which files are currently opening by compiler, which flags are passed. This is complicated but reliable way though.

ContentLicense: CC BY-SA 3.0

Title: Finding header files


问:
Releasing an open source project without getting embarrassed
I've been working by myself on a fairly large open source project for quite a while and it's nearing the point where I'd like to release it. However, I'm self-taught and I don't really know anyone who could adequately review my project.

A few years ago, I had released a small bit of code which pretty much got ripped apart (in a critical sense) on the forum where I released it. Even though the code worked, the criticism was accurate but brutal. It prompted me to begin searching for best practices for everything and in the end I feel that it made me a much better developer. I've gone over everything in my project so many times trying to make it perfect that I've lost count.

I believe in my project and think it has the potential to help a lot of people and I feel like I've done some cool things in interesting ways with it. Still, because I'm self-taught, I can't help but wonder what gaps exist in my self-education. The way my code was ripped apart last time isn't something I'd like to repeat. I think my two biggest fears with releasing my project that I've poured countless hours into are being absolutely embarrassed because I missed some patently obvious things because of my self-education or, worse, releasing it to the sound of crickets.

Is there anyone who has been in a similar situation? I'm not afraid of constructive criticism, so long as it is constructive and not just a rant on how I screwed up. I know there is a code review site on StackExchange, but it's not really set up for large projects and I didn't feel like the community there is large enough yet to get good feedback if I were to post parts of my project piecemeal (I tried with one file). What can I do to give my project at least some measure of success without getting embarrassed or devestated in the process?

答:
Unless the project is aimed for developers (eg: a development framework, in which case you WANT them to criticize it if it makes you learn even more), you shouldn't worry. But even then, there are many open source projects aimed for developers that are crap, yet people love them because they go to the point (think of Codeigniter, which is very poorly architected, and yet it is the most popular php framework)

If it is an application for regular humans, they will probably only care about the results.


问:
What to use for simple cross-platform games instead of Flash?
In short, for simple games:

Is Flash still a good option for browser-based PC clients? It still has 90%+ penetration.

What is a good alternative for mobile devices? Is HTML5 + JavaScript the choice for mobile? Or does one have to learn a new native language for each target platform? (Android, Apple, Windows Phone)...

If you desire further background: There are more blogs about the official demise of mobile Flash than I can count, along with endless useless and vitriolic comments. I'm actually trying to do something practical: build simple games that can be served accross multiple platforms. Several months ago I plopped down $1100 for CS5.5 Web and am wading into Flash. Bummer. My question to people who actually develop simple games and apps: What platform should I use instead? Is Flash still a sensible platform for web-served PC users?

For example, let's say I build a simple arcade game that I would like to serve as an app to mobile users and as a browser-based game to PC users. Should I still invest the time and effort to learn and develop in Flash for the PC users, while building a parallel code set in some other language for mobile users? My games are simple enough that it would be annoying but not inconceivable to maintain parallel code sets.

答:
An interesting Java-based approach that is used by one of the games I have on my phone is explained here - basically the API starts with Java and as well as standard JAR files, outputs the same content in numerous other formats including Flex, HTML5 and XCode, ready for cross platform deployment.

An approach like that will be limited to what is common to all platforms, but for the basic stuff it is pretty neat.


答:
As a general rule of thumb, open sourced programs have three groups of people who look at the source code.

People who are considering modifying the code to make the program work slightly differently for them, to port it to a different platform, or as a jumping-off point for their own programs.  If they don't like the code, they typically just won't use the code, and you'll never hear from them.

Students, trying to learn how to code in the language you used.  These will almost never contact you, but you may occasionally receive an e-mail asking why you did something one way vs. another.  (To be fair, I haven't actually had one of these e-mails in many years.  I think that web sites like StackExchange may have replaced this interaction)

Security researchers, such as the guys at OpenBSD, trying to decide whether your tool is secure enough to be included in their distribution.  If it's not, but they do still want to include your program, then they'll be in touch to figure out a way to secure it.  (And if your program becomes popular, I imagine that it will probably attract black hat researchers as well, who won't contact you no matter what they find.)

In the real world, people really won't read your source code for any other reason than these, because they simply don't need to.  You only got such a volume of feedback before because you posted the code on a forum, which implied that you wanted to receive feedback on the code.

I don't think you really need to worry about a torrent of abuse;  the only people likely to contact you at all are people who want to add features or fix bugs, who have already browsed through the codebase and haven't run screaming for the hills.  ;)

Title: Releasing an open source project without getting embarrassed

Body:
I've been working by myself on a fairly large open source project for quite a while and it's nearing the point where I'd like to release it. However, I'm self-taught and I don't really know anyone who could adequately review my project.

A few years ago, I had released a small bit of code which pretty much got ripped apart (in a critical sense) on the forum where I released it. Even though the code worked, the criticism was accurate but brutal. It prompted me to begin searching for best practices for everything and in the end I feel that it made me a much better developer. I've gone over everything in my project so many times trying to make it perfect that I've lost count.

I believe in my project and think it has the potential to help a lot of people and I feel like I've done some cool things in interesting ways with it. Still, because I'm self-taught, I can't help but wonder what gaps exist in my self-education. The way my code was ripped apart last time isn't something I'd like to repeat. I think my two biggest fears with releasing my project that I've poured countless hours into are being absolutely embarrassed because I missed some patently obvious things because of my self-education or, worse, releasing it to the sound of crickets.

Is there anyone who has been in a similar situation? I'm not afraid of constructive criticism, so long as it is constructive and not just a rant on how I screwed up. I know there is a code review site on StackExchange, but it's not really set up for large projects and I didn't feel like the community there is large enough yet to get good feedback if I were to post parts of my project piecemeal (I tried with one file). What can I do to give my project at least some measure of success without getting embarrassed or devestated in the process?


问:
Differences between programming in school vs programming in industry?
A lot of students when they graduate and get their first job, feel like they don't really know how to program even though they may have been good programmers in college.

What are some of the differences between programming in an academic setting and programming in the 'real world'?

答:
At University...

Your teacher gives you:

A well defined, isolated problem, the solution of which can be provided within a short and well-defined time span (and it will be discarded afterward)

A well-defined set of tools that you were introduced to prior to assignment

A well-defined measure for the quality of your solution, with which you can easily determine whether your solution is good enough or not

In the "Real World"...

The problem is blurry, complex and embedded in context. It's a set of contradictory requirements that change over time and your solution must be flexible and robust enough for you to react to those changes in an acceptable time.

The tools must be picked by you. Maybe there's already something usable in your team's 10-year-old codebase, maybe there's some open source project, or maybe a commercial library or maybe you will have to write it on your own.

To determine whether the current iteration of your software is an improvement (because you're almost never actually done with a software project), you need to do regression testing and usability testing, the latter of which usually means that the blurry, complex, contradictory, context-embedded requirements shift once again.

Conclusion

Programming in school and programming in the real world are so inherently different to the point where there's actually very little overlap. CS will prepare you for "real world" software development like athletics training would prepare an army for battle.


答:
Use HTML5 and javascript, with some components in flash or native code as needed. Mostly that comes down to performance optimization - get the algorithm working in pure javascript, then replace parts of it with calls to flash or a phonegap plugin if you need to.

Generally you won't need to do too much of this - the only area javascript really seems to have problems is dealing with large amounts of binary data. You do need to be careful with how you handle graphics, particularly around knowing which parts will use hardware acceleration, but if you get it right the performance is good enough for most purposes.

The one area where you may run into real problems with javascript is if you need to support IE - not only is its javascript engine orders of magnitude slower than other browsers, but you need to run a whole lot more code to make up for missing features. The same approach should work, though you may find yourself implementing more components in flash than you would otherwise.

Title: What to use for simple cross-platform games instead of Flash?

Body:
In short, for simple games:

Is Flash still a good option for browser-based PC clients? It still has 90%+ penetration.

What is a good alternative for mobile devices? Is HTML5 + JavaScript the choice for mobile? Or does one have to learn a new native language for each target platform? (Android, Apple, Windows Phone)...

If you desire further background: There are more blogs about the official demise of mobile Flash than I can count, along with endless useless and vitriolic comments. I'm actually trying to do something practical: build simple games that can be served accross multiple platforms. Several months ago I plopped down $1100 for CS5.5 Web and am wading into Flash. Bummer. My question to people who actually develop simple games and apps: What platform should I use instead? Is Flash still a sensible platform for web-served PC users?

For example, let's say I build a simple arcade game that I would like to serve as an app to mobile users and as a browser-based game to PC users. Should I still invest the time and effort to learn and develop in Flash for the PC users, while building a parallel code set in some other language for mobile users? My games are simple enough that it would be annoying but not inconceivable to maintain parallel code sets.


问:
Do you start writing GUI class first or reverse?
I want to write my first Java program, for example Phonebook, and I wonder what to do first. My question is should I write GUI classes first or util classes first?
I am database developer and want to know best practice in building program.</p>

答: If you are a database developer I think you should start with a data model and create a good abstraction layer so that it is easy to define your user interface (be it GUI or not).</p>


问:
Does Java have automatic memory management?
I have started learning about C# and I come to what is called 'Automatic memory management' or 'Garbage collectors' and I'm wondering if Java contains something like this as well? and if it does, does it do that as effective as C# when it comes to windows desktop application and web applications?</p>

答: Yes, Java does have garbage collection and "effective" is a relative term hard to judge without some more specific criteria.</p>


答: Java is a garbage collected language though the collection model is different than C#'s. Effectiveness would vary considerably depending on the structure of the program but Java does run just fine on Windows and the Web.</p>

Title: Does Java have automatic memory management?

Body: I have started learning about C# and I come to what is called 'Automatic memory management' or 'Garbage collectors' and I'm wondering if Java contains something like this as well? and if it does, does it do that as effective as C# when it comes to windows desktop application and web applications?</p>


问:
Dependency Injection: Only for single-instance objects?
What if I want to also decouple my application, from classes like Product or User? (which usually have more than one instance)

Take a look at this example:

```<code>class Controller {
    public function someAction() {
        $product_1 = new Product();
        $product_2 = new Product();
        // do something with the products
    }
}
</code>```

Is it right to say that Controller now depends on Product?

I was thinking that we could decouple them too (as we would with single-instance objects like Database)

In this example, however ugly, they are decoupled:

```<code>class Controller {
    public function someAction(ProductInterface $new_product) {
        $product_1 = clone $new_product;
        $product_2 = clone $new_product;
        // do something with the products
    }
}
</code>```

Has anyone done something like this before? Is it excessive?

答:
When I first learned about unit testing and the real power of abstraction layers, I wanted to put an interface on everything. And I did. And I learned very quickly that there is a "too far."

Assuming that you're not dealing with sub-types of products, there is absolutely no benefit to your decoupling. All you achieve is creating another place where you have to replicate any changes you make to the Product's interface.

That said, I don't think the line that I'd draw here is between single-instance and multiple-instance classes. But that may be because I don't like making things single-instance unless they need to be -- controllers and databases are not good examples, to my mind.

Choose not to have an abstraction until you need one (although, if you're unit testing properly then you will probably need one on all but the domain objects). And choose to make a class multiple-instance until it needs to be single-instance.


答:
Start with the domain or what you call 'util classes'. Test it independently of your UI implementation. That way you get a better understanding of how your application behaves (or should behave), how the logic plays out regardless of which UI framework, MVC or whatnot, tools, styles you're planning to use in the end.

Binding yourself to a specific UI implementation is usually a bad idea. I'm not saying that you shouldn't consider it up front. I'm saying that your application shouldn't be dependent on it. The UI tends to change A LOT over the course of a project and if your domain is tied to it then you'll be changing your domain a lot as well.

Title: Do you start writing GUI class first or reverse?

Body:
I want to write my first Java program, for example Phonebook, and I wonder what to do first. My question is should I write GUI classes first or util classes first?
I am database developer and want to know best practice in building program.</p>


问:
Why decouple view and controller (web)?
Why can't we put them in the same page, like each action paired up with its view? Not using code island, but controller code at top then view code at bottom? What are the problems with this approach?

By MVC, I am referring to frameworks such as ASP.NET MVC and Ruby on Rails, and I am under the impression that the V and C are actually the UI layer.

答:
The reason why they are generally decoupled is because you want your view to use a controller in order to get at your model. But the architecture should allow you to replace one view with another one without having to change business logic (i.e. object model or how those objects are retrieved).

By not tying your controller directly to the view, later on it would me much more easier to add other functionality like import/export which can use the controller/model directly without having to rely on any UI.

Another advantage of pushing as much code as possible out of the UI is because UIs are much harder to unit test than business layer behind them.  By separating as much as you can out of the view itself, you can write much more unit tests to ensure your controller/model and application logic are correct.

Title: Why decouple view and controller (web)?


答: You don't have to separate the two of course. But if view and controller is independent then any user interface can be used. For example you can use the controller through console, sockets, web, or desktop interface. In other words, you can increase the code reuse.</p>

Title: Why decouple view and controller (web)?

Body:
Why can't we put them in the same page, like each action paired up with its view? Not using code island, but controller code at top then view code at bottom? What are the problems with this approach?

By MVC, I am referring to frameworks such as ASP.NET MVC and Ruby on Rails, and I am under the impression that the V and C are actually the UI layer.


问:
What techniques would you use for a next generation java web application?
I'm working at a site similar to Foursquare and Yelp, with approximately 100000 unique requests each week that generates content, growing steadily. We are currently using:

Seam as Java web framework.

MySQL as DB

Hibernate as ORM

Hibernate Search as Index

EhCache for Caching.

Since our site is slowly growing out of the current setup and has a lot of legacy code, it is time for us to start thinking about a major refactoring/changing setup.

Web framework

We are not ready to change the language but we are leaning towards Spring Web Framework, since:

Seam is no more.

Almost all of us have worked with Spring and liked it.

DB and ORM

We have done a little research and we are thinking about MongoDB.

Index

Do we need to have a separate Index if we use MongoDB?

Cache

?

So my question is basically:

If you take Spring Web Framework and MongoDB into consideration, how would a good setup be for a web application that is growing and handles a lot of logged in users generating input and performing searches?

EDIT
I would like to thank all of you for taking the time to answer me, but the answer I'm looking for should be more specific:

"We choose Spring as our web framework and Freemarker as our template language since freemarker is fast.... If you use MongoDB you will not need a separate index for doing geo searches since MongoDB supports location-based queries out-of-the-box... I very good cache solution to this setup is.... In my previous project we chose to use Apache Solr as our search platform because this solved the issue with fast updates..."

Thank you // Jakob

答:
Matt Raible's comparison presentation is pretty weak and a bit biased (the latter I read on the net). As it often happens the answers we get plainly follow from criteria we choose. However different audience quite naturally has different criteria. Examples. Student will prefer something that is described in a textbook he can take in the library. Big company CEO will probably (it happens often) prefer something sold by a brand name company (like IBM). Small company will have a chance to choose a technology that most of the engineers know or prefer. Scientist will have his own approach.

In fact there are very very few honest publications comparing several Java Web Frameworks. Matt's work put all criteria he knows in a big heap and missed some other. I do not recall him even mentioning such criteria as "component-oriented" which is crucial (if not a synonym) for code reuse.

Spring may be good but not in the presentation layer. AFAIK it usually uses Struts which is way obsolete. As minimum because it is bound to JSP which is definitely (by definition from Oracle included in Java EE 6) obsolete. In fact it got obsolete way before that.

Consider using HybridJava for presentation layer with FANTASTIC performance.

@maple_shaft "HybridJava ... is interesting but it looks very green" - In some way yes - not widely used yet. Tools like plugins still in early development stage. On the other hand in its scientific base it does not change already for 2 years. Specifically - the language does not change (and hence code of compiler does not change). And even no change is expected here. If you can add some idea here - try, the team will be happy to implement! Ironically the tutorial will not get any bigger - right because one of the major aims was to make all describable in just few pages and exactly in that HybridJava excelled.

Use it and it'll become yellow.


答: Start with the part of the project you find most interesting. If you start with the part you don't like you might quit before you make progress. Where you start is mostly a matter of preference so you might as well choose what you most want to work on. </p>


答:
The controller handles bussiness logic which may change from time to time , and the View may remain unchanged , as per requirements.

The vice versa of the above is also true.

Designers and Developers need to be able to work on the same project independently.

A nice post: http://mashable.com/2011/11/12/designer-collaboration-strategies/

The whole system becomes more maintainable. Solving bugs gets easier with the decoupled approach.

Web standards with front end technologies are changing at a fast pace. Imagine a corporation deciding to migrate all the front-end technlogies to HTML5 , Dart , etc.  Having a coupled View and Controller would be a nightmare !

Title: Why decouple view and controller (web)?


答: Yes, the algorithm used by the Microsoft's 'Common Language Runtime' is known as the Mark-Compact Algorithm. I also read that the Java Runtime uses this as well. Also, if you run into any other C# vs Java sort of comparison like questions, this document may be of interest. A Comparison of Microsoft's C# Programming Language To Sun Microsystems' Java Programming Language, By Dare Obasanjo.</p>


问:
What programming problems are best solved by using pointers?
Well, I basically understand how to use pointers, but not how best to use them in order to do better programming.

What are good projects or problems to resolve involving the use of pointers so I can understand them better?

答:
I see pointers as my index finger, we use to do a couple of things:

when someone asks you for something you can't carry, like where is street so and so, I would "point" at this street, and that's what we do in case of arguments by reference

when counting or traversing through something, we would use the same finger, and that's what we do in arrays

please forgive this poor answer


问:
Why did visual programming never take off and what future paradigms might change that?
As the number of "visual" OS's such as Android, iOS and the promised Windows 8 are becoming more popular, it does not seem to me that we programmers have new ways to code using these new technologies, due to a possible lack in new visual programming languages paradigms.

I've seen several discussions about incompatibilities between the current coding development environment, and the new OS approaches from Windows 8, Android and other tablets OS's. I mean, today if we have a new tablet, it's almost a requirement for coding, to have, for instance, an external keyboard (due it seems to me it's very difficult to program using the touch screen), exactly because the coding assistance is not conceived to "write" thousands of lines of code.

So, how advanced should be the "new" visual programming languages paradigms? Which characteristics these new paradigms would be required?

答:
Think of movies. This is the most "visual" medium in the arts, with color, movement, 3d etc.etc.

Now think about how they are made. Everybody works from a script. There may be some drawings and set designs attached. But it starts with a script and the day to day shooting is dictated by the script.

Language and text are incredibly powerful and expressive tools, visual tools are good for explaining, illustrating and simplifying things but the lack precise control is awkward.
Also you lose track of whats happening in a complex diagram much more quickly that you do with well organized text.

In the datawarehouse space its pretty common to use "Visual" development environments for ETL. While this makes the simple things simpler its a nightmare to implement anything complex. Things like impact analysis become fiendishly difficult, and, source code control is almost impossible -- You know something has changed but finding out what becomes a "spot the difference" puzzle.

OwnerDisplayName: Rego


问:
Recommend Stanford Online Database Class?
I am taking the Stanford Online Machine Learning class which is outstanding. http://ml-class.org

Is anyone taking the Stanford Online Database class: http://www.db-class.org? Does it seem useful if you have a few years of fairly simple database experience, but no formal education in the area? Or is it mostly academic and not relevant to developing and maintaining databases in the "real world"?

答:
I'm taking it right now and I'd say it's worth taking, though I can't really speak to its real world relevance since my job doesn't involve databases of any kind.

The class is structured very similarly to the Machine Learning class, with videos and quizzes done in the same style. There are no programming assignments similar to the ones in the advanced track of the Machine Learning course in this offering, but there are quizzes that include writing some relational algebra and SQL queries as well as specifying some XML DTD and Schema markup.

I came into this course with a minimal knowledge of SQL and I'm finding it to be a good overall introduction to the subject. So far we've covered principles of relational design, SQL fundamentals, XML schemas, and relational algebra. The video lectures go into both the theoretical background of each topic as well as some real-world caveats to watch out for.

Here's the list of the topics covered by the video lectures in this session. I've added a short description in brackets for the modules I've watched so far.

XML Data (DTD, XML Schema)

Relational Algebra (formal query language)

SQL (basic query commands)

Relational Design Theory (Normalization, BCNF, 4NF)

Querying XML

UML

Indexes

Constraints and Triggers

Transactions

Views

Authorization

Recursion

Online Analytical Processing

NoSQL Systems

I'm not sure how much "developing and maintaining" we'll cover in the rest of the course, but if you're interested in the theoretical background, an orderly approach to learning about the design and usage of RDBMSs, and some graded practice exercises to check your understanding, this course may be for you.


答: Almost everyone will have a different method for developing that suits their style. For example, one person may find that its easier to design their GUI if they have defined the underlying architecture and data storage.  Another person may find however that playing around with the GUI and getting an initial draft may help them better organize their storage system and code their program in a more organized manner.  The task before you will be to find out which method (or perhaps some hybrid of the two) works best for you.  For me, I prefer to do an initial mockup of what I think the GUI will look like, then begin working on the nuts and bolts of the application.  Once I've done that I typically come back and make changes to the GUI as needed.  My recommendation to you is to pay careful attention as you work on small projects and get a feel for the approach that helps you most.</p>


答:
I've have a little experience with graphical programming, and for the most part that experience has been bad.  Most of these systems are simple flow-charting systems, which are fine if you work on very simple systems.  I've also used a data transformation tools with a graphical editors (essentially XSLT without the syntax).  Again, for very simple transforms it was ok, but for anything real it was unusable.

There are things to consider that are rarely taken into account in these systems.

Most programs these days are concurrent, and rely on mechanisms in the language for co-ordinated state change.  Most flowcharting tools have no mechanism for organizing concurrent computations. An exception are implementations BPMN. This is a graphical notation for BPML, which has a strong theoretical foundation in the process calculi.  While BPML is intended to be a complete implementation of the pi-calculus, it's adoption is weak, however a watered-down version called BPEL is gaining popularity as part of the WS stack.

Exception handling also tends to be weak in flowcharting systems - complex software needs good exception handling.

But beyond the lack of features,  the graphical programming systems I used were just painful to work with. It's hard to fit more than a dozen elements on the screen at a time before it gets to be a mess. You are constantly moving from mouse-to-keyboard and back.  Coding in a text editor with syntax highlighting and auto complete take a fraction of the time.

Title: Why did visual programming never take off and what future paradigms might change that?

Body:
As the number of "visual" OS's such as Android, iOS and the promised Windows 8 are becoming more popular, it does not seem to me that we programmers have new ways to code using these new technologies, due to a possible lack in new visual programming languages paradigms.

I've seen several discussions about incompatibilities between the current coding development environment, and the new OS approaches from Windows 8, Android and other tablets OS's. I mean, today if we have a new tablet, it's almost a requirement for coding, to have, for instance, an external keyboard (due it seems to me it's very difficult to program using the touch screen), exactly because the coding assistance is not conceived to "write" thousands of lines of code.

So, how advanced should be the "new" visual programming languages paradigms? Which characteristics these new paradigms would be required?


答:
Actually,

it is impossible to fully distinguish between academic level programming and real world programming.

I'd say the biggest difference might be this:
in real world programming - you have to know more than programming, and should be able to adapt fast.

Depending for which sector you are doing work, you have to be in compliance with its laws.

Michael only touched the tip of the iceberg by stating programming related tasks, which I would classify as the easy stuff (if you are worth the dough you are being paid).

In general you'll face at least a couple of challenges per subject in an industry:

Governing laws (ex. client confidentiality for medical)

Subject know-how (ex. invoicing-tax system, inventory, resource management, medical schemes, industry standards)

Client requirements that are lacking or non-existant or differing from industry standards/governing laws

If you compare a research phd level programming project vs. a real world one, chances are they are very similar in difficulty, entrance level know-how and such.

The only real difference then is that the real world project

has a client

has budgets (time, money, people resources)

It's different ball game when someone else makes the rules :)

Title: Differences between programming in school vs programming in industry?

Body:
A lot of students when they graduate and get their first job, feel like they don't really know how to program even though they may have been good programmers in college.

What are some of the differences between programming in an academic setting and programming in the 'real world'?


答:
Personally, I would analyze the user concerns and go from there. Ideally, the aspect of the application that requires the most amount of work should start first.

In this scenario, I'd focus on UI mocks as a primary focus. The customer has expressed concern over supporting a diverse end user group, especially those with visual impediments, and distributing the system across cultural lines. Thus, while having a functional and stable system will be critical, the importance of having an interface that will allow users to easily accomplish work takes precedent.

This scenario would have me focusing on the domain logic. The customer has requested a system with complex business interactions. It will store large amounts of complex data structures. Thus initial work discovering and implementing the business logic with data source storage will lead to a successful project.

If the system is a personal project, then focus on what you want to learn from the project. If I am trying out a new technology, I try to focus on a small spike with it and isolate the technology itself so I can better grasp how it works. However a personal project that goes through all the stages will have the benefit of better preparing you for "real" projects. In that case, I'd outline some major goals and use those as a stepping stone. If this phone book app is a personal project of yours, I would suggest working through the UI first. As a database developer, I am assuming that you know how to connect databases to domain logic and roughly how to write domain logic, but have not explored UI technologies as much; thus working on the UI should benefit your learning more than starting from the data source or domain logic.


问:
What should I do to be language-agnostic?
By now I work with asp.net and C#. I have done a decent work in Java as well. I am planning my career in such a way I should be language-agnostic someday. What are the things that I need to learn?

First would OOP paradigms as its speaks about the Class design. Are there any others?

答:
To be language agnostic you need to have experience in all of the common styles and types of languages.

An imperative language (You tell it what to do, step by step. Eg - C)

A declarative language (You tell it your goal, it figures out what to do. Eg - SQL/HTML/Prolog)

Also:

A functional language (Functions are key, avoiding state and side effects are the goals. Eg - Haskell/OCaml/Lisp/F#)

An object oriented language (Architecture where objects encapsulate related data and the methods that act on them). Eg - Java/C#)

Some typing styles:

A statically typed language (Data types are defined and checked at compile time. Eg - C#)

A dynamically typed language (Data types are checked at runtime. Eg - Python/Javascript)

Experience of strong vs. weak typing is also useful.

Some different runtime styles:

Something compiled (Eg - C++)

Something interpreted (Eg - PHP)

Something Managed (Eg - C#/Java)

Lower level stuff:

Something fairly low level (Eg - C)

Some dialect of assembly (Eg - NASM)

On top of that I would say you need experience of some concurrent programming and something event driven. You should probably also make sure you know something about the various domains such as web programming (client & server), rich client development/desktop, games. You might also want to learn about embedded programming, or dedicated hardware (like games consoles), and mobile development is becoming an increasingly relevant domain.

Others have also mentioned that it's worth getting some experience of Generic programming and Meta programming approaches.

When you learn these paradigms avoid just learning the syntax and writing in your old style. I've seen many C# devs write JavaScript as if it's statically typed. Don't do this, try to learn the language paradigms and embrace them.

If you've done all of this, the differences between languages will become largely syntactical so switching will become a fairly simple exercise of learning some new syntax.

Don't forget though that modern programming is almost always dependant on a framework, so familiarising yourself with the common and popular frameworks for each language you learn is also critical. Knowing C# is irrelevant without .net.

ContentLicense: CC BY-SA 2.5


问:
Beginner's guide to writing comments?
Is there a definitive guide to writing code comments, aimed at budding developers?

Ideally, it would cover when comments should (and should not) be used, and what comments should contain.

This answer:

Do not comment WHAT you are doing, but WHY you are doing it.

The WHAT is taken care of by clean, readable and simple code with proper choice of variable names to support it. Comments show a higher level structure to the code that can't be (or is hard to) show by the code itself.

comes close, but it's a little concise for inexperienced programmers (an expansion on that with several examples and corner cases would be excellent, I think).

Update: In addition to the answers here, I think this answer to another question is highly relevant.

答:
You should be aware of the greatest weakness of comments: they grow stale.  That is, as code changes, developers rarely update comments to stay in sync with the code.  This means, that you can never trust them and still end up reading the code.  For this very reason, your code should be self documenting.  You should be choosing your function and variable names in such a way that the code reads like prose.  </p>

<p>So don't document WHAT the code is doing. Self-documenting code should take care of that.  Document WHY you are doing it.  The WHY's are usually business rule related or architecture related and won't change often and go stale as fast at the WHATs.  Document edge cases.  Document exceptions.  Document design decisions.  And most importantly document those design decisions you had considered, but decided not to implement (and document WHY you decided against using them). </p>

OwnerDisplayName: Cameron

Title: Beginner's guide to writing comments?

Body:
You should be aware of the greatest weakness of comments: they grow stale.  That is, as code changes, developers rarely update comments to stay in sync with the code.  This means, that you can never trust them and still end up reading the code.  For this very reason, your code should be self documenting.  You should be choosing your function and variable names in such a way that the code reads like prose.

So don't document WHAT the code is doing. Self-documenting code should take care of that.  Document WHY you are doing it.  The WHY's are usually business rule related or architecture related and won't change often and go stale as fast at the WHATs.  Document edge cases.  Document exceptions.  Document design decisions.  And most importantly document those design decisions you had considered, but decided not to implement (and document WHY you decided against using them).

OwnerDisplayName: Dmitry Beransky


答: I just follow one simple and common principle: Your comments should not say what code is doing, but why it is doing it. Martin Fowler Article and Book on Re-factoring and Code Complete book has loads of information, but regrettably it is not in a summarized form to my knowledge.</p>

Title: Beginner's guide to writing comments?

Body:
Is there a definitive guide to writing code comments, aimed at budding developers?

Ideally, it would cover when comments should (and should not) be used, and what comments should contain.

This answer:

Do not comment WHAT you are doing, but WHY you are doing it.

The WHAT is taken care of by clean, readable and simple code with proper choice of variable names to support it. Comments show a higher level structure to the code that can't be (or is hard to) show by the code itself.

comes close, but it's a little concise for inexperienced programmers (an expansion on that with several examples and corner cases would be excellent, I think).

Update: In addition to the answers here, I think this answer to another question is highly relevant.

OwnerDisplayName: Shahzeb


答:
In theory, there are at least five possible approaches.

Top-Down:

Start with UI mock-shots or a paper prototype. Turn them into real dialogs, and work your way from the button handlers and other controls down through the logic and to the database.

Bottom-Up:

Start with the data structures (probably the database schema). Then add logic (modelling real-world processes); finally, your UI is just an interface to trigger the logic and display the results.

Logic first:

Start with the program logic, implementing data access and a rudimentary UI as needed. Then formalize and harden the data structures, and finally flesh out the UI properly.

Meet in the middle:

Start with database schema and UI, and simultaneously work towards the point where they meet. With this approach, the logic comes last.

Horizontal expansion:

Start by identifying the absolute minimum amount of functionality that would do something interesting, and implement the whole stack (data structures, logic, and UI) for this part. It could be just a basic CRUD cycle with a simple edit dialog for just one entity. Then start adding more features, implementing the whole stack for each feature (hence 'horizontal').

Each of these has pros and cons.

Top-down gives you something visible early in the process, and allows you to check your functional design with stakeholders - mock-shots often tell users more about a design than flowcharts or walls of text.

Bottom-up gives you a chance to design a rock-solid database schema before you commit to anything; since a database schema is notoriously hard to modify once released, you want to get this part right - the impact of modifying a UI is much smaller and produces fewer and less severe bugs.

Logic-first means you can test the logic before spending serious time on the database and the presentation, which is especially interesting if your logic is going to be really complex.

Meet-in-the-middle combines the advantages of bottom-up and top-down, but you'll have to jump back and forth between two tasks, and you risk ending up with logic that is more complex than necessary because your two ends don't meet naturally.

Horizontal expansion goes well with an iterative workflow, and it has the added advantage that, if you prioritize well, you will have a working application at any given time, so if you don't make a deadline, you will have a version that has fewer features, but is still fully functional, as opposed to a version that has a complete database, but no UI at all.

So which one you choose depends on your personal style, and on the circumstances.


问:
Should one use pseudocode before actual coding?
Pseudocode helps us understand tasks in a language-agnostic manner. Is it best practice or suggested approach to have pseudocode creation as part of the development lifecycle? For instance:

Identify and split the coding tasks

Write pseudocode

Get it approved [by PL or TL]

Start Coding based on Pseudocode

Is this a suggested approach? Is it practiced in the industry?

答:
There tend to be a couple circumstances where pseudocode tends to get broken out in my work, which is in academia where programming tends to get used as a tool or the "and now we solve it" filling in the middle of a project:

When the code is going to be more counter-productive to an actual understanding of what's going to happen than pseudo-code will be. SAS for example, will take up half the whiteboard doing some fairly basic programming tasks. See also C, which some other posters have discussed.

With a lot of data analysis and statistics coding, there tends to be a lot of tinkering with the code as results are generated. Pseudocode is somewhat easier to use for "herein lies a back-and-forth process, if the diagnostic plot doesn't look right, try X".

Students learn lots of different programming languages. For example, among people I know, a statistics problem might be analyzed in SAS, R or Stata. Something that requires something closer to traditional programming might be done in R, Matlab, C, C++, Java, Python... it really depends on what particular student is implementing the program, and for what purpose. But it's still useful for the Java people and the Python people and the Matlab people to have a joint idea of what the others are doing, and how the approach, rather than the code itself, works.


问:
What's the point of adding Unicode identifier support to various language implementations?
I personally find reading code full of Unicode identifiers confusing. In my opinion, it also prevents the code from being easily maintained. Not to mention all the effort required for authors of various translators to implement such support. I also constantly notice the lack (or the presence) of Unicode identifiers support in the lists of (dis)advantages of various language implementations (like it really matters). I don't get it: why so much attention?</p>

答: I think it makes a lot of sense to allow unicode characters in strings and comments. And if the lexer&parser have to support unicode for that anyway, the compiler writer probably gets unicode character support in identifiers for free, so it would seem like an arbitrary limitation to allow only ASCII characters in identifiers.</p>


答:
Code Complete, as mentioned, has various guidelines on writing comments. In short, it's PDL and can be summed up as:

Describe your intent, not what the code is doing. Avoid describing implementation details unless you are using some trick or you are using custom-implementations. For example, using shifting bits to divide, using pointer arithmetic to access class members or using a custom memory allocator for some pooled objects.

Write the pseudo code (i.e, the comments) first, then write the in real code after you have finished describing your routine/method/function. The language used is high-level yet specific, so it can be rather verbose

Have an idea of what your code is doing even before writing the code

Have comments as close as to the actual code

The goal is to avoid long winded unrelated comments that may be outdated, but to have comments reflecting the intent and purpose of the code. Using a high level pseudo code also helps to clarify your thinking before writing the implementation.

There's a link at GameDev.net [which explains PDL][1], in case you don't want to track down the book.

Title: Beginner's guide to writing comments?


问:
Programming to ANSI standards (for engineering)
I am currently tasked to write a software to help engineers design standard compliant designs. If there is a bad design, software will report an error or warning.

Maybe it's just me, but anyone who has done this should be familiar with the massive amounts of ANSI standards tables like this one: http://en.wikipedia.org/wiki/Nominal_Pipe_Size

Computers are, as its name suggest, computing machines, not lookup machines. I feel that feeding formulas into computers and churning out standard compliant designs is much more efficient than doing memory intensive data lookups that are prone to human input errors and susceptible to "data updates".

I actually think that there are formulas to calculate all those numbers, but nobody so far could give me that information. Anyone been through this before? What is THE best approach to this? Thanks for sharing.

答:
I think what you are going to find is that while computers are computing machines, the ANSI standards you are trying to enforce were mostly written by committees which consist of people, who are not computing machines.  While I'm sure some things are going to be formula-based and by all means if that's the case, use formulas, I think you will also find plenty of standards which are table based simply because humans came up with them and simply listing a table was the most logical thing for them to do.  If that's the case, you will probably have to resort to storing/accessing tables in your app as well.

Maybe to minimize user-error you should design a mechanism that makes it super easy to import table data from other sources/documents so that your final end-user isn't actually required to punch in table data, which would definitely be error-prone.  Once the data is in there, I doubt you'll have any runtime problems with using lookup tables and considering how much memory is accessible to a modern process, I doubt that your app would even be considered memory-intensive.

Also keep in mind that there's plenty of examples where computers use lookup tables, for example rainbow tables, which are used for in anti-encryption, are just giant lookup lists that can easily reach half a terabyte in size.


答: You should read Robert C. Martin's Clean Code book.  It nicely explains that if you need comments, most likely you are not coding properly.  Ideally, your code should be "self commenting."  The Clean Coder book explains how to do this, so that comments are not necessary, and it described well how to do comments in situations where it is necessary.  (Such as explaining a complex mathematical formula)

Title: Beginner's guide to writing comments?


问:
How large is ok for a Class?
I’m a long time developer (I’m 49) but rather new to object oriented development. I’ve been reading about OO since Bertrand Meyer’s Eiffel, but have done really little OO programming.

The point is every book on OO design starts with an example of a boat, car or whatever common object we use very often, and they start adding attributes and methods, and explaining how they model the state of the object and what can be done with it.

So they usually go something like "the better the model the better it represents the object in the application and the better it all comes out".

So far so good, but, on the other hand, I’ve found several authors that give recipes such as “a class should fit in just a single page” (I would add “on what monitor size?" now that we try not to print code!).

Take for example a PurchaseOrder class, that has a finite state machine controlling its behavior and a collection of PurchaseOrderItem, one of the arguments here at work is that we should use a PurchaseOrder simple class, with some methods (little more than a data class), and have a PurchaseOrderFSM “expert class” that handles the finite state machine for the PurchaseOrder.

I would say that falls in the “Feature Envy” or “Inappropriate Intimacy” classification of Jeff Atwood's Code Smells post on Coding Horror. I’d just call it common sense. If I can issue, approve or cancel my real purchase order, then the PurchaseOrder class should have issuePO, approvePO and cancelPO methods.

Doesn’t that goes with the “maximize cohesion” and “minimize coupling” age old principles that I understand as cornerstones of OO?

Besides, doesn’t that helps toward the maintainability of the class?

答: I fully agree with the use of the single responsibility principle for classes but if that's followed and results in large classes then so be it. The real focus should be that individual methods and properties are not too large, cyclomatic complexity should be the guide there and following that may result in many private methods that will increase the overall class size but will leave it readable and testable to a granular level. If the code remains readable then size is irrelevant.</p>

Title: How large is ok for a Class?


问:
When to favor ASP.NET WebForms over MVC
I know that Microsoft has said

ASP.NET MVC is not a replacement for WebForms.

And some developers say WebForms is faster to develop on than MVC.  But I believe speed of coding comes down to comfort level with the technology so I don't want any answers in that vein.

Given that ASP.NET MVC gives a developer more control over their application, why isn't WebForms considered obsolete?  Alternatively, when should I favor WebForms over MVC for new development?

答:
I have read all the answers and feels my personal experience would add something to the answers above.

3-4 years back, I developed 2-3 website projects using Webforms. Around that time, MVC wasn't around or i didn't heard of it. The development was naturally(I was coming from Win-forms development with no prior web development experience) fast for me, since i need not to learn HTML in details and web-controls helped a lot (a hell lot, it made life easier).

Now, after all that time, i wasn't working any web project until recently and merely building some windows application using WPF.

Few days back I had an idea for a website and thought of developing it : this time around in MVC (since its talked about everywhere, besides i needed to learn either, so i choose MVC). The project is still in development phase, since i am still learning and building together.

So, the Key differences i find b/w the two are following :-

For someone coming from windows development, Web forms will always be favorable. Asp.net learning curve for a windows developer is bit steep

For someone coming from web development in some other technology, MVC will be favoured since it mocks the latest of them all.

Development is easier and cleaner in MVC if you are equipped with good knowledge of HTML and CSS

Deployment is still an issue. In web forms one just needed to do copy and paste. But, this requires some things to be done.

In short, both of them will stay here for a while.

Title: When to favor ASP.NET WebForms over MVC


问:
Should the developer be involved in setup of test data in QA and UAT environment?
When QA or UAT comes, should the developer still be involved in setting up data or finding test data for the QA tester or business user? Or will this introduce bias to the developer who coded the system changes that are being tested in the said environments?</p>

答:
You should weigh the bias against the potentially saved labor. The developer brings a good amount of knowledge about the system and potential test cases, and can certainly help and shorten the process. I would normally put the burden of avoiding bias on the QA or business person - it's part of their job.

However, this depends for a good part on the actually involved persons. With the wrong combination of personalities, group-think becomes a major issue and the developer will taint the testing with too much of a developer's perspective.


答:
This is a fairly straightforward project where I'd say it's not that important.  On many projects though it's not going to be immediately clear exactly how you want the GUI to look and operate, and once you make it someone may ask you to change it.  It's good to make quick mockups of the GUI so you or whoever is in charge can come to a concrete decision on what it should look like and then this will give help you see some of the correletive pieces of data you'll need to track that you might not have noticed had you started with the data design.

More importantly, you do NOT want your data design to drive your user interface.  Relatively speaking, I believe fixing poor GUI implementations is far easier than fixing poor data implementations.  So I definitely vote for starting with the GUI.

And I'm more of a database guy myself, just fyi.


问:
Differences between programming in school vs programming in industry?
A lot of students when they graduate and get their first job, feel like they don't really know how to program even though they may have been good programmers in college.

What are some of the differences between programming in an academic setting and programming in the 'real world'?

答:
Update: As if someone was reading my mind: Graduate expectations versus reality...

My take, two other factors:

Problem size: In academia, I mostly had to develop software "from scratch", which meant that most of the time, the largest program I had encountered was the largest one I wrote. This de-emphasises the necessary capability to handle and cope with complexity that emerges from different pieces of software interacting together. If I was aware of the effort needed to comprehend with complexity, I might have chosen not to be in the industry at all.

Reading VS Writing: Another side effect of problem size is that often, in the "real world" we are exposed to work that has been written by others, either for maintenance purposes (I did no maintenance in academia anywhere), extension, or simply division of labour. Therefore reading code becomes many times more important than writing it.

A proposal for improved programming education: Academia should expose us more to real-world situations without regressing to vocational training. Doctors have to face a corpse at some point to see if they are "made for it" (I've heard stories of people dropping the course after this experience). If I had seen in my early twenties a 20K LOC project comprised of different programming styles, which I had to understand in one day and amend a bug in three, I might have considered other career options -- though probably not.


答:
Depends heavily on what kind of resources/people the organization has access to, and it depends on the people themselves.

Some organizations can't afford not to utilize developers in this area.  And some developers are as good or better at QA then the QA people are, while others are lacking in this area.  There's no reason to make a blanket statement and say it should be one way or the other.

You want to have a good QA person/team.  If your developer has this skill then that's a bonus you shouldn't pass up.

Title: Should the developer be involved in setup of test data in QA and UAT environment?

Body: When QA or UAT comes, should the developer still be involved in setting up data or finding test data for the QA tester or business user? Or will this introduce bias to the developer who coded the system changes that are being tested in the said environments?</p>


问:
Releasing an open source project without getting embarrassed
I've been working by myself on a fairly large open source project for quite a while and it's nearing the point where I'd like to release it. However, I'm self-taught and I don't really know anyone who could adequately review my project.

A few years ago, I had released a small bit of code which pretty much got ripped apart (in a critical sense) on the forum where I released it. Even though the code worked, the criticism was accurate but brutal. It prompted me to begin searching for best practices for everything and in the end I feel that it made me a much better developer. I've gone over everything in my project so many times trying to make it perfect that I've lost count.

I believe in my project and think it has the potential to help a lot of people and I feel like I've done some cool things in interesting ways with it. Still, because I'm self-taught, I can't help but wonder what gaps exist in my self-education. The way my code was ripped apart last time isn't something I'd like to repeat. I think my two biggest fears with releasing my project that I've poured countless hours into are being absolutely embarrassed because I missed some patently obvious things because of my self-education or, worse, releasing it to the sound of crickets.

Is there anyone who has been in a similar situation? I'm not afraid of constructive criticism, so long as it is constructive and not just a rant on how I screwed up. I know there is a code review site on StackExchange, but it's not really set up for large projects and I didn't feel like the community there is large enough yet to get good feedback if I were to post parts of my project piecemeal (I tried with one file). What can I do to give my project at least some measure of success without getting embarrassed or devestated in the process?

答:
I really don't get the psychology behind this question... a better question to ask yourself would be "what do I have to lose by releasing this software"

Even if your project is full of code smells, do you have to lose anything?

Even if the code is awful and someone takes the time to write a flame-mail to you, guess what, he probably used your software enough to want to make some changes to it and make it better.

You should be happy about that! Accept the criticism and make your code better, ask the angry guy who took the time to write to you. He cares!

After a while the flame-mails will stop, people will keep using your software, you will have learned from your mistakes and the gaps you didn't know existed in your education will not be there anymore.

I'd much rather work with someone who is willing to do something, admit their mistakes, fix them and keep going than someone who's not willing to do anything.

If you are really not comfortable releasing the software under your name then release it under a nickname. If it succeeds claim it as your own, if not change your nickname :)


问:
Single click handler for all buttons in Javascript? Is it a pattern? Whats the benefit?
I have been told that when there are multiple buttons on the page for same purpose but targeting different item e.g. delete item on a grid of items, they say it is recommended to just register for click handler only on the top most element like 'body' and check what was clicked instead of hooking up click with every delete button.

Whats the benefit of this? Creating more handlers causes problems? Is it an optimization of some sort? Is it a pattern? Does it have anything to do with performance? Where can I read more about it?

答:
Its an "idiom" not a "pattern".

This advantage in JS is that the identity of the button is "this" so you can interrogate the "this" variable to find out about which button was pressed.

Its a nifty shortcut if you have lots of similar processing with small variations.


问:
Real performance of node.js
I've got a question concerning node.js performance.

There is quite lot of "benchmarks" and a lot of fuss about great performance of node.js. But how does it stand in real world? Not just process empty request at high speed.

If someone could try to compare this scenario:

Java (or equivalent) server running an application with complex business logic between receiving request and sending response.

How would node.js deal with it? If there was need for a lot of JavaScript processing on server side, is node.js really so fast that it can execute JavaScript, and stand a chance against more heavyveight competitors?

答: The benchmarks you refer to are exactly that. They are real world tests with fixed variables (hardware ect). Without those controlls the results will vary so much they will be meaningless</p>

Title: Real performance of node.js


答:
Who are you? Are you someone whom people know as the God programmer, and worries that your reputation will come down? Are you the one who is going to apply for the job and worries that the employer may read these criticism, and think that you are bad programmer?
What I am asking is why are you afraid of criticism about how you screw up. You get to decide which are genuine comments and which are rants. Take the good ones as defects and fix them in next version. I am just feeling that you are worrying unnecessary about the criticism. You are helping the open source community, that itself is a very good cause. Please keep up the good work.  </p>


答:
Event-driven paradigms are inherently faster than multi-threaded paradigms because there is no context switching. While one "thread" is running, the rest are blocked until that thread hits a point where it no longer needs the processor (e.g. if it is waiting for a response from, say, the database). So you shouldn't be surprised if the benchmarks show that.

However, it does require that programmers know exactly what they're doing at a much lower level. If they don't release the waiting threads while the current thread is "waiting," it's suddenly going to be a lot less efficient than multi-threaded.

You should also bear in mind that practically no one will write a Node.js enterprise application, because actual coding efficiency would be low. They are more likely to write an enterprise application in one of the many frameworks appearing that are built on top of Node.js.

So you cannot fairly compare, say, Node.js to MVC for ASP.NET. You should compare it to something written directly in the .NET Framework.

Title: Real performance of node.js

Body:
I've got a question concerning node.js performance.

There is quite lot of "benchmarks" and a lot of fuss about great performance of node.js. But how does it stand in real world? Not just process empty request at high speed.

If someone could try to compare this scenario:

Java (or equivalent) server running an application with complex business logic between receiving request and sending response.

How would node.js deal with it? If there was need for a lot of JavaScript processing on server side, is node.js really so fast that it can execute JavaScript, and stand a chance against more heavyveight competitors?


答:
While developer bias with creation of the test code is a risk, many times the developer knows how to do it more quickly than the QA resources could.  I have set up test data and environments for QA resources before and it tends to work out in one of two ways:

The QA team could do it eventually, but they are not as efficient or quick.  They also VERY clearly understand the requirements and already have their test cases planned and ready to go regardless of what you help them with.  This is when it is okay.

The QA team is incapable of even doing the simplest tasks or anything that can be remotely conceived as critical thinking.  They depend on the developer to provide them with test data, environments and even a test plan.  A better QA team can probably be assembled by driving around behind a Home Depot with an empty-bed truck and yelling out "Trabajo!".  This is when it is a bad thing!

In other words, if they NEED you to do this then it is a bad idea, if they WANT you to do this, then it is probably okay.


问:
Detail of acceptance criteria in user story
I have the following example for a user story with acceptance criteria.

I would like to know if I am allowed to describe how the GUI must be changed to support the new feature. How much detail can acceptance criteria have?

This is my example:

User Story:

As forum administrator I will connect persons in groups, so that people can get organized.

Acceptance Criteria:

The creation of a person group happens below a person group pool (person group pool is an object also visually available in the current software system)

The creation happens with a context menu of the persongroup pool. Below the pool one can create new groups.

A person group contains: person group-ID, description, remark

May that be relevant an right acceptance criteria? Because I describe how you can create a new group by opening a context menu.

答:
Acceptance criteria needs to have enough detail to be accurate. The developer should be able to look at the acceptance criteria and answer the question "am I done?" and not have to worry that the product owner will come back to them and say "you forgot feature X".

Strictly speaking, anything that is not mentioned in the acceptance criteria is optional.

In your case, you wrote "May that be relevant an right acceptance criteria? Because I describe how you can create a new group by opening a context menu." If having it implemented with a context menu is important and will be used to judge if the feature is complete or not, the context menu must be part of the acceptance criteria.


答:
This is not a yes/no kind of question. Rather, one should wonder when to use pseudo-code. It is important to understand the problem before designing a solution, and it is important to have a clear view of the solution before you implement it.
Pseudo-code can be used in any of these steps:

When defining the problem, it's common to write down use cases, sometimes using sequences of actions.

When designing a solution. Class diagrams are nice, but they only describe the "static" part, i.e. the data. For the dynamic part, as soon as you need to deal with a loop and non-trivial data, I find pseudo-code to be the best method available. Graphical alternatives include state machines (good for complex control flow with little data) and dataflow diagrams (good for simple flows with complex data).

When implementing the solution (or just before). Some programming languages are hard to read (think, assembly). An alternative representation can be valuable in this case. If you are unfamiliar with the languages, it's also worth doing.

Pseudo-code that's actually proper code in a high-level language is also used, it's usually called prototyping.

In addition to achieving understanding, pseudo-code is also good for communication.

If you are wondering if you should use pseudo-code on a regular basis, I am personally against all kinds of rigid rules. This can easily turn into a boring waste of time if used for trivial problems everybody in the team understands. Using pseudo-code for specifications that you maintain throughout the project's life can also be costly and offer little value.

Title: Should one use pseudocode before actual coding?

Body:
Pseudocode helps us understand tasks in a language-agnostic manner. Is it best practice or suggested approach to have pseudocode creation as part of the development lifecycle? For instance:

Identify and split the coding tasks

Write pseudocode

Get it approved [by PL or TL]

Start Coding based on Pseudocode

Is this a suggested approach? Is it practiced in the industry?


问:
Objective-C As A First OOP Language?
I am just finishing the second semester of my CS degree. So far I learned C, all the fundamental algorithms and data structures (e.g., searching, sorting, linked lists, heaps, hash tables, trees, graphs, etc).

Next year we'll start with OOP, using either Java or C++.

Recently I got some ideas for some iPhone apps and got itchy to start working on them.

However I heard some bad things about Objectice-C in the past, so I am wondering if learning it as my first OOP language could be a problem. Not to mention that I think it will be hard to find books/online courses that teach basic OOP concepts using Objective-C to illustrate the concepts (as opposed to books using Java or C++, which are plenty), so this could be another problem.

In summary: should I start learning Objective-C and OOP concepts right now by my own, or wait one more semester until I learn Java/C++ at university and then jump into Objective-C?

Update: For those interested in getting started with OOP via Objective-C I just found some nice tutorials inside Apple's Developer Library -> http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/OOP_ObjC/Introduction/Introduction.html

答:
Whatever you do, you will need to (re)learn OOP several times to really program in a OO manner.

So it won't hurt if you start early.

And by the way, you will also hear bad things about Java, bad things about C++, bad things about Ruby given the people you talk to... If you listen to them, you might never start learning OOP :)

Edit to answer this new part of the question:

Not to mention that I think it will be hard to find books/online
  courses that teach basic OOP concepts using Objective-C to illustrate
  the concepts (as opposed to books using Java or C++, which are
  plenty), so this could be another problem

That is not a problem, that is great. OOP concepts vary from one language to another. An "interface" exists in Java, is a bit different in Objective-C, can be implemented in some manner with C++ but does not exist in Ruby for example.
Learning OOP with examples in a language and applying it in another language is a great way of opening your mind and not being tied to one language.

Title: Objective-C As A First OOP Language?


答:
I would be very skeptical. First of all I never put the onclick in the HTML but always attach it later with jquery or the like, so the added size of the HTML is not really an issue.

Past that you will need quite a bit of logic in the callback to figure out what to do with the click event. I would rather have a bunch of simpler functions than one really complex one.

Title: Single click handler for all buttons in Javascript? Is it a pattern? Whats the benefit?

Body:
I have been told that when there are multiple buttons on the page for same purpose but targeting different item e.g. delete item on a grid of items, they say it is recommended to just register for click handler only on the top most element like 'body' and check what was clicked instead of hooking up click with every delete button.

Whats the benefit of this? Creating more handlers causes problems? Is it an optimization of some sort? Is it a pattern? Does it have anything to do with performance? Where can I read more about it?


答:
Recently I got some ideas for some iPhone apps and got itchy to start working on them.

Working on what you're itchy about is MUCH better than suppressing the itch and learning some "better" language instead. Life's just too short, you know?

EDIT: In response to your comment, I do both, and the concepts largely translate. The syntax is very different, obviously. The two languages emphasize different conventions and design patterns, for sure. But working in more than one language makes you a better developer. You start thinking behind the structures that one language leans on, and you see the bigger picture behind them both. Honestly, the biggest thing you'll have to deal with is the difference in typing rules between the two, and the runtime-vs-compiletime differences.

Title: Objective-C As A First OOP Language?

Body:
I am just finishing the second semester of my CS degree. So far I learned C, all the fundamental algorithms and data structures (e.g., searching, sorting, linked lists, heaps, hash tables, trees, graphs, etc).

Next year we'll start with OOP, using either Java or C++.

Recently I got some ideas for some iPhone apps and got itchy to start working on them.

However I heard some bad things about Objectice-C in the past, so I am wondering if learning it as my first OOP language could be a problem. Not to mention that I think it will be hard to find books/online courses that teach basic OOP concepts using Objective-C to illustrate the concepts (as opposed to books using Java or C++, which are plenty), so this could be another problem.

In summary: should I start learning Objective-C and OOP concepts right now by my own, or wait one more semester until I learn Java/C++ at university and then jump into Objective-C?

Update: For those interested in getting started with OOP via Objective-C I just found some nice tutorials inside Apple's Developer Library -> http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/OOP_ObjC/Introduction/Introduction.html


问:
Does unit testing lead to premature generalization (specifically in the context of C++)?

Preliminary notes

I'll not go into the distinction of the different kinds of test there are, there are already a few questions on these sites regarding that.

I'll take what's there and that says: unit testing in the sense of "testing the smallest isolatable unit of an application" from which this question actually derives

The isolation problem

What is the smallest isolatable unit of a program. Well, as I see it, it (highly?) depends on what language you are coding in.

Micheal Feathers talks about the concept of a seam: [WEwLC, p31]

A seam is a place where you can alter behavior in your program without editing in that place.

And without going into the details, I understand a seam -- in the context of unit testing -- to be a place in a program where your "test" can interface with your "unit".

Examples

Unit test -- especially in C++ -- require from the code under test to add more seams that would be strictly called for for a given problem.

Example:

Adding a virtual interface where non-virtual implementation would have been sufficient

Splitting -- generalizing(?) -- a (smallish) class further "just" to facilitate adding a test.

Splitting a single-executable project into seemingly "independent" libs, "just" to facilitate compiling them independently for the tests.

The question

I'll try a few versions that hopefully ask about the same point:

Is the way that Unit Tests require one to structure an application's code "only" beneficial for the unit tests or is it actually beneficial to the applications structure.

Is the code generalization that is needed to make it unit-testable useful for anything but the unit tests?

Does adding unit tests force one to generalize unnecessarily?

Is the shape unit tests force on code "always" also a good shape for the code in general as seen from the problem domain?

I remember a rule of thumb that said don't generalize until you need to / until there's a second place that uses the code. With Unit Tests, there's always a second place that uses the code -- namely the unit test. So is this reason enough to generalize?

答:
Unit test -- especially in C++ -- require from the code under test to add more seams that would be strictly called for for a given problem.

Only if you don't consider testing an integral part of problem solving. For any nontrivial problem, it ought to be, not only in the software world.

In the hardware world, this has been learnt long ago - in the hard way. The manufacturers of various equipment have learnt through centuries from countless falling bridges, exploding cars, smoking CPUs etc. etc. what we are learning now in the software world. All of them build "extra seams" into their products in order to make them testable. Most new cars nowadays feature diagnostic ports for the repairmen to get data about what's going on inside the engine. A significant portion of the transistors on every CPU serve diagnostic purposes. In the hardware world, every bit of "extra" stuff costs, and when a product is manufactured by the millions, these costs surely add up to large sums of money. Still, the manufacturers are willing to spend all this money for testability. Probably they have figured (or learnt the hard way) that the risk of their product failing in the hands (or under the bums) of end users, and the ensuing loss of reputation, lawsuits, bad PR etc. etc. etc. is way higher than the cost of designing and making their product testable from the start.

Back to the software world, C++ is indeed more difficult to unit test than later languages featuring dynamic classloading, reflection etc. Still, most of the issues can be at least mitigated. In the one C++ project where I used unit tests so far, we didn't run the tests as often as we would in e.g. a Java project - but still they were part of our CI build, and we found them useful.

Is the way that Unit Tests require one to structure an application's code "only" beneficial for the unit tests or is it actually beneficial to the applications structure?

In my experience a testable design is beneficial overall, not "only" for the unit tests themselves. These benefits come on different levels:

Making your design testable enforces you to chunk your application into small, more or less independent parts which can only influence each other in limited and well defined ways - this is very important for the long term stability and maintainability of your program. Without this, the code tends to deteriorate into spaghetti code where any change made in any part of the codebase may cause unexpected effects in seemingly unrelated, distinct parts of the program. Which is, needless to say, is every programmer's nightmare.

Writing the tests themselves in TDD fashion actually exercises your APIs, classes and methods, and serves as a very effective test to detect whether your design makes sense - if writing tests against and interface feels awkward or difficult, you get valuable early feedback when it is still easy to shape the API. In other words, this defends you from publishing your APIs prematurely.

The pattern of development enforced by TDD helps you focus on the concrete task(s) to do, and keeps you on target, minimizing the chances of you wandering off solving other problems than the one you are supposed to, adding unnecessary extra features and complexity, etc.

The fast feedback of unit tests allows you to be bold in refactoring the code, enabling you to constantly adapt and evolve the design over the lifetime of the code, thus effectively preventing code entropy.

I remember a rule of thumb that said don't generalize until you need to / until there's a second place that uses the code. With Unit Tests, there's always a second place that uses the code -- namely the unit test. So is this reason enough to generalize?

If you can prove that your software does precisely what it's supposed to do - and prove it in a fast, repeatable, cheap and deterministic enough way to satisfy your customers - without the "extra" generalization or seams forced by unit tests, go for it (and let us know how you do it, because I am sure a lot of people on this forum would be as interested as me :-)

Btw I assume by "generalization" you mean things like introducing an interface (abstract class) and polymorphism instead of a single concrete class - if not, please clarify.


答:
I have zero personal experience with programming training in school--I was an English major. Ask me about Keats and Byron!--but I have received several new grads and brought them up and mentored them in the world of professional software development. So I can speak from that perspective.

My experience is that really ALL they got from their schooling was an interest in programming. Their skills varied from zero to negligible. Their ability to self-direct was nonexistent even in the highest-skilled of them. Their thinking wasn't just small-scale; they actually thought in miniature. A system comprising more than a couple dozen lines of code made them fall entirely to pieces.

But you know what? They acquired an interest, and that's a big deal. An interest is plenty. I can work with someone who's interested. I can turn them into a developer, provided they come to me with an interest in being one. Hell, that's all I started with. That and an appreciation for post-modern American novelists.


答:
TDD and Unit Testing, is good for the program as a whole, and not just for the unit tests. The reason for this is because it is good for the brain.

This is a presentation about a specific ActionScript framework named RobotLegs.  However if you flip through the first 10 slides or so, it starts getting to the good parts about the brain.

TDD and Unit testing, forces you to behave in a manner which is better for the brain to process and remember information.  So while your exact task in front of you is just making a better unit test, or making code more unit testable... what it actually does is make your code more readable, and thus make your code more maintainable.  This gets you coding in habbits faster, and gets you able to comprehend your code faster when you need to add/remove features, fix bugs, or in general open up the source file.

Title: Does unit testing lead to premature generalization (specifically in the context of C++)?

Body:
Preliminary notes

I'll not go into the distinction of the different kinds of test there are, there are already a few questions on these sites regarding that.

I'll take what's there and that says: unit testing in the sense of "testing the smallest isolatable unit of an application" from which this question actually derives

The isolation problem

What is the smallest isolatable unit of a program. Well, as I see it, it (highly?) depends on what language you are coding in.

Micheal Feathers talks about the concept of a seam: [WEwLC, p31]

A seam is a place where you can alter behavior in your program without editing in that place.

And without going into the details, I understand a seam -- in the context of unit testing -- to be a place in a program where your "test" can interface with your "unit".

Examples

Unit test -- especially in C++ -- require from the code under test to add more seams that would be strictly called for for a given problem.

Example:

Adding a virtual interface where non-virtual implementation would have been sufficient

Splitting -- generalizing(?) -- a (smallish) class further "just" to facilitate adding a test.

Splitting a single-executable project into seemingly "independent" libs, "just" to facilitate compiling them independently for the tests.

The question

I'll try a few versions that hopefully ask about the same point:

Is the way that Unit Tests require one to structure an application's code "only" beneficial for the unit tests or is it actually beneficial to the applications structure.

Is the code generalization that is needed to make it unit-testable useful for anything but the unit tests?

Does adding unit tests force one to generalize unnecessarily?

Is the shape unit tests force on code "always" also a good shape for the code in general as seen from the problem domain?

I remember a rule of thumb that said don't generalize until you need to / until there's a second place that uses the code. With Unit Tests, there's always a second place that uses the code -- namely the unit test. So is this reason enough to generalize?


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

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

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

答:
Stimulating, not intrusive music.

This is my work playlist


答: I am a firm believer not just in open source, but in open development, where people can see the complete evolution of your code. From hair-brained prototype to working code...you shouldn't ever be embarrassed. You are putting yourself out there - that takes guts. Own it and be proud of it. Nobody is perfect.


答:
Your code has problems. So does mine. Anybody else answering this question? Their code has problems too.

Unless it's, say, 10 lines or less, it's flawed. Maybe tragically so.

To be a developer is to CONSTANTLY mash yourself up against the limits of your abilities and understanding. It may not be like this for ALL developers, but for me and for the ones I know, we work right at the edge of our competency pretty much at all times. And you face that over and over and over, then have a nice weekend, then come back Monday and do it over and over and over again.

Having worked that life for 15 years, the thing I've settled on is this one fact: You are not your code. You WRITE code. Judgement of the code is NOT judgement of you. Your code has problems, some you know about, some you don't. Having that brought to your attention helps you, unless all you can do about that is feel bad. Feeling bad doesn't improve your code, it just makes you feel bad.

You write your code, and you write it as well as you know how. Maybe tomorrow you'll know more than you did today, but today you did it as well as you knew to. My advice is: write today's code today and tomorrow's code tomorrow. Then have a nice weekend and come back on Monday to write Monday's code.


答:
If you are genuinely worried, simply use an online pseudonym when releasing the software.  Then there is no way it will impact on your real-life reputation.

When/If you do receive public criticism, that'll lead to improvements in the code and will help you grow as a developer.  That is a good thing.

I find that for my projects most constructive criticism/suggestions are sent privately rather than broadcast publicly, and even then you'll be unlikely to receive a flood of comments.  Therefore, I recommend to just go for it!

Good luck.


答:
I strongly agree with what other posters have said: Even if your code is crappy and not high quality - most people simply don't care. Everyone who has dived into OpenSource code at one time or another may have thought to himself "WTF happened here".

But I don't know anyone out there with the motivation to criticize the codebase of a project just for the sake of saying "dude, your code looks awful!". We've all been there and we all know that any code we're writing right now will seem pretty lame for ourselves in only a few feeks (mine definitely will).

So don't worry that much - people simply have a lot better to do in their spare time than nitpicking on the code of OpenSource projects.


答:
There is nothing wrong with self-study in and of itself.  You can't be isolated and peer code reviews can help with that.

You also need to focus on what you are doing.  Why do you care if you get negative feedback on your work?  If it's because you are making the assumption that if you get criticism it's because the code is bad or you aren't any good at programming, that may or may not be true.

The purpose of the effort is to make sure the code works and to get the best code out as possible, but from practical experience, not all the commericial code out there is stellar either.  Sometimes you get bad requirements, sometimes you don't have time to do it right.  Sometimes developers want to come across as a genius by making others look bad.

I don't believe you can learn without making some mistakes, especially if it's something that takes real discipline and effort.  If it was easy, everyone would be doing it.  Just try to limit mistakes to minor ones, using established best practices.  I realize that isn't always possible!

If I worried about what others thought of me as a programmer, I wouldn't have gone into the field in the first place.  That being said, my first take at criticism of the code is, try to take it objectively and learn from it.


问:
Is there an open source license for this?
I have written code at home, on my own time and using my own knowledge and equipment, while under no contract or NDA.  I want to make this code open source so that I can use it in software I write for an employer, without denying myself the right to use it at home or elsewhere later.

I'm not sure if saying it is in the "public domain" would fit this purpose, or if I need to find an open source license.  I want anyone to be able to use the code in closed source proprietary software with zero requirements for including a license with the source or binary.  And I want to minimize the risk of anyone being sued for using it.  (I'm aware that one can never be 100% safe from being sued.)

Is there an open source license that fits this purpose?  To what extent is what I want to do even possible?

I wouldn't mind putting the license in comments in the code files themselves, but that obviously doesn't go with the binary.

答:
My advice is... discuss this with your employer.

My employer uses code that I had already written, and we agreed that I would license the code under the 2-clause BSD license and then give a copy to my employer.  In practise, I simply added a header to each source file based on the BSD 2-Clause license template.  That is the easy bit.

What happens with enhancements/fixes made to your code by the employer?  When these are done by you?  When these are done by another developer?  In my case we agreed that I would not directly take improved source code, but I would be free to reimplement any changes in my own time, on my own hardware.


问:
Is it wise to ask about design decisions made on a product during an interview?
I've been thinking about interview questions lately and I've been reflecting on bad interview experiences I've had in the past. One of particular note is where I had asked the interviewer why the team chose to use EJB 3 over Spring in their product. The interviewer pretty much tore my face off, yelling "Because Spring is not the be all and end all of Java software development, do you want this job or not?".  In response to this, I told him that this probably wasn't the job for me and I promptly walked out of the interview.

I was informed at the beginning of the interview that the company had high staff turnover, the product they were working was initially created in Modula-3 then ported to Perl and finally to Java. I was handed a 10 page booklet of technical questions covering Java, EJB, SQL and JDBC and I was asked questions about the technology stacks I've worked with. When prompted to ask questions, I felt it was reasonable to ask them about their technology stack and and get reasonable answers back, not to send the interviewer into flames.

Question:
Is it a good idea to probe on architectural choices taken in an interview? If not, why?

From my own point of view, an interview is a two-way process. If the interviewers are testing me on my technical skills, I've got every right to ask them the same questions to:

1) Figure out what their mindset and attitudes towards developing software are.
2) Determine if their approach is in line with how I would approach problems of that kind.

It's possible that the interviewer who got angry had poor interviewing skills and forgot that an interview is a two-way exchange. If I was asked this, I would have given a reasonable answer, but I certainly wouldn't have tried to put an interviewee in a state of meek capitulation where the head just bobs up and down with no conversation.

答:
I'm of the mindset it's essential.  I've worked at far too many jobs with nonsensical design decisions either because nobody knew any better, didn't care to learn, or there was a mandate from management to use whatever the CEO read about in a magazine/saw online/had someone tell him was the "next big thing" without any consideration of alternatives.  These jobs were all miserable places to work.

You shouldn't necessarily criticize a design decision unless it's something that spits in the face of common sense or just sounds like crazy talk, but it's common to question things that seem "off" to find out if there's a legacy reason or something that came up that facilitated the need for using an unorthodox approach.

Asking questions like this also has the effect of gauging the company's interest in improvement and competency.  As someone else above said, it's one thing if you get an answer like (I don't know Java but use .NET so will use .NET examples) When we wrote the app there were no mature ORMs, so we used stored procedures with a data gateway layer.  We'd like to move to Entity Framework in the future and another thing entirely to get an answer like We just use stored procedures.  Entity Framework looks scary and might require work to refactor, and we can't refactor anything because the CEO has a laundry list of new features he wants us to work on, and if we spend the time looking at Entity Framework he'll fire us for wasting time.  One indicates understanding and a desire to improve, the other indicates a mediocre at best environment where everyone does the bare minimum to scrape by.

A company that takes offense at you questioning their decisions or wanting to discuss why they chose to use Product A instead of Product B is playing their hand and showing that they don't want a free thinker but a drone who won't question, and chances are it's not the kind of company any competent developer wants to work for.