答:
One big reason was Windows, especially Windows 3.1 and a little later, Windows 95 and NT 3.51. Consumers particularly loved the GUI interfaces as opposed to the old text based systems of Unix and DOS. This meant more average people would purchase computers for home use. Also, the explosion of the Internet in the mid-90's increased sales.

Prices for PC's also dropped throughout the 90's until they reached the point where they are today. This was due to the economies of scale presented by an increased consumer and business demand. For example, all five of my current computers cost less combined than the one 486 desktop I purchased in 1992.

Now, in a way he might be right but in an unexpected direction. The rise of mobile devices, smartphones and tablets, have partially brought about simplified operating systems and may reduce the prominence of x86. However, they go far beyond what was predicted in 1992.


问:
Why was Tanenbaum wrong in the Tanenbaum-Torvalds debates?
I was recently assigned reading from the Tanenbaum-Torvalds debates in my OS class. In the debates, Tanenbaum makes some predictions:

Microkernels are the future

x86 will die out and RISC architectures will dominate the market

(5 years from then) everyone will be running a free GNU OS

I was a one year old when the debates happened, so I lack historical intuition. Why have these predictions not panned out? It seems to me, that from Tanenbaum's perspective, they're pretty reasonable predictions of the future. What happened so that they didn't come to pass?

答:
Microkernels are the future
  x86 will die out and RISC architectures will dominate the market
  (5 years from then) everyone will be running a free GNU OS

It depends how you view and define future, in the traditional sense his predictions have failed.

However the time has not yet ended (another deeper discussion aside).

Thus, things still could change:

Microkernels or some variant could make a comeback

RISC/ARM may well dominate -> tablets / mobiles

10 or 15 years from now. Who knows, open source is changing the world slowly..

ContentLicense: CC BY-SA 3.0


问:
How can we reduce downtime at the end of an iteration?
Where I work we practice scrum-driven agile with 3-week iterations. Yes, it'd be nice if the iterations were shorter, but changing that isn't an option at the moment.

At the end of the iteration, I usually find that the last day goes very slowly. The actual work has already been completed and accepted. There are a couple meetings (the retrospective and the next iteration planning), but other than that not much is going on.

What sort of techniques can we as a team use to maintain momentum through the last day? Should we address defects? Get an early start on the next iteration's work anyway? Something else?

答:
All the developers in my team use the free time towards the end of a sprint (provided that all sprint tasks are finished) as 'Google time'.

This is where each developer works on his/her own idea/project as long as it benefits the company. I strongly suggest putting a system like this in place, this has really increased job satisfaction levels within our team.


答:
Microkernels are the future

I think Linus hit the points on monolithic kernels in his debate. Certainly some lessons learned from microkernel research was applied to monolithic kernels. Microsoft sometimes used to claim that the Win32 kernel was a microkernel architecture. It's a bit of a stretch when you look at some textbook microkernels, but the claims had some technical justification.

x86 will die out and RISC architectures will dominate the market

If you back up from desktops and servers, RISC dominates the processor market by any measure. ARM (R stands for RISC) outsells x86 in number of processors, there are more ARM processors than x86 processors in use, and there is more total ARM computing capacity than x86 computing capacity. This year, a single ARM vendor (yeah, Apple) may outsell all x86 vendors combined. Only in the desktop and server space does x86 dominate. So long as Windows is the dominant platform for desktop computers and Linux for servers, this is likely to continue to be true for a while.

There's a part b to this as well. Intel engineers did some amazing work to squeeze life out of their instruction set, even to the point of making a RISC core with an opcode translator that sits on top. Compare to one of the dominant RISC desktop chip makers, IBM, who could not get a power-efficient and high performance G5 for Apple laptops in a reasonable timeframe.

(5 years from then) everyone will be running a free GNU OS

I think the various OS vendors still offer compelling value propositions on their OSes. GNU isn't even necessarily the most important player in the Open Source community, so even a more widespread adoption of open source software didn't necessarily translate into GNU OSes. Yet, there's a whole lot of GNU stuff out there (all Macs ship with GNU's Bash, for example. There's probably some GNU system tools on Android phones). I think the computer ecosystem is a lot more diverse than Tanenbaum foresaw, even when you restrict your view to desktop computers.

Title: Why was Tanenbaum wrong in the Tanenbaum-Torvalds debates?

Body:
I was recently assigned reading from the Tanenbaum-Torvalds debates in my OS class. In the debates, Tanenbaum makes some predictions:

Microkernels are the future

x86 will die out and RISC architectures will dominate the market

(5 years from then) everyone will be running a free GNU OS

I was a one year old when the debates happened, so I lack historical intuition. Why have these predictions not panned out? It seems to me, that from Tanenbaum's perspective, they're pretty reasonable predictions of the future. What happened so that they didn't come to pass?


问:
Does Scrum turn active developers into passive developers?
I'm a web developer working in a team of three developers and one designer. It's now about five months that we've implemented the agile scrum software development methodology. But I have a weird feeling I just wanted to share in this site.

One important factor in human life is decision-making process. However, there is a big difference in decisions you make. Some decisions are just the outcome of an internal or external force, while other decisions are completely based on your free will, and some decisions are simply something in between. The more freedom you have in making decisions, the more self-driven your work would become. This seems to be a rule. Because we tend to shape our lives ourselves.

There is a big difference between you deciding what to do, or being told what to do.

Before scrum, I felt like having more freedom in making the decisions which were related to development, analysis, prioritizing implementation, etc. I had more feeling like I'm deciding what I'm doing.

However, due to the scrum methodology, now many decisions simply come from the product owner. He prioritizes PBIs, he analyzes how the software should work, even sometimes how the UI and functionality should be implemented. I know that this is part of the scrum methodology, and I also know that this may result in better sales of product in future. However, I now feel like I'm always getting told to do something, instead of deciding to do something. This syndrome now has made me more passive towards the work.

I tend to search less to find a better solution, approach, or technique

I don't wake up in the morning expecting to get to an enjoyable work. Rather, I feel like being forced to work in order to live

I have more hunger to work on my own hobby projects after work

I won't push the team anymore to get to the higher technological levels

I spend more time now on dinner, or tea-times and have less enthusiasm to get back to work

I'm now willing more for the work to finish sooner, so that I can get home

The big problem is, I see and diagnose this behavior in my colleagues too. Is it the outcome of scrum? Does scrum really makes the development team feel like they have no part in forming the overall software, thus making the passive to the project?
How can I overcome this feeling?

答: In our team, the product owner tells us what to do and we decide how we do it. It is really important to have this separation or you'll end up in the situation you have described.


答:
Ultimately it all comes down to the fact that things don't really like to change.

We didn't migrate to a better-architected microkernel because monolithic ones were easier to create, ran faster, and everyone knew how to build them. Also because Linux was developed as a monolithic kernel and became popular, there were no microkernels that achieved enough success to take off. (its a bit like the same reason we all run Windows, we run Windows because everybody runs Windows)

RISC, others have pointed out that x86 is pretty much a RISC architecture nowadays, with a CISC wrapper on top for backwards compatibility.

A lot of people are running a free GNU OS - on the server. The web is pretty much driven by it. Nobody notices because all the clients are Windows. Back in those days, you had a choice: Linux that was still very much a hobby OS; a flavour of Unix but you couldn't afford to buy it; or cheap n cheerful Windows. Linux took too long to replace Unix, and still doesn't quite have enough of a compelling solution to running on the desktop (partly because of ideological problems with different Window systems, binary graphics drivers, and the lack of a stable ABI). It's doing rather well in other non-desktop markets like embedded and mobile however.


答:
All are true if you don't think that a computer is something on your desktop.

True - microkernels never worked because they were never micro enough. If the whole of your stripped down embedded linux is smaller than the x86 specific bit of the MACH kernel is the question of micro-kernels relevent?

RISC is dominating the market. More ARM cpus are sold each year than X86 cpus ever. You are probably never more than 6ft from an ARM cpu.

Almost everybody is running linux, it's in their router, their TV setop box, their Tivo and their Android phone - they just don't know that these have an OS


问:
When you write wrappers for APIs how do you handle usage errors?
When you write wrappers for APIs how do you handle usage errors?

Do you assume that the user uses it right and write the wrapper such that it makes the call to the server and let the server return the error?

Or do you check for the missing parameters and return an error? If yes, how do you convey the error? a string or an error code?

答:
Think wrapper vs adapter vs bridge from a design pattern point of view. You might have a new perspective and find your answer from there.

E.g. Adapters and Wrappers from Andy Kramek and lots more if you google.

ContentLicense: CC BY-SA 2.5


问:
How to introduce a computer illiterate 50-year old to programming
The other day my dad asked me a question that I would have never expected from him.

"How can I learn C++?"

My dad is turning 56 this year and computers are a distant concept for him. He doesn't know how to use a phone very well besides calling numbers (no speed dial or contacts); though he has started to learn computers a little better - to the point that he knows how to open the internet (in Windows) and browse around (and has successfully completed several job applications entirely on his own online, of which he was offered positions too). But still, these are too narrow-windowed experiences to mean much, really.

While he may not have the background, my dad knows how to read. And I mean reading as a skill, not just an ability. He has little to no college education (financial problems, family, etc.) and was fortunate enough to finish high school, but still taught himself to become a master electrician and has been one for almost 30 years now. He did the same with guitar, learning to play at a very professional level and has been praised for his skill. In high school, he picked up a weight lifting book - and was the only person in his high school at the time to qualify officially as an "athlete" by national standards.

In all cases, he just needed something to read. Something to teach him. He absorbs information like a sponge.

I have no doubt in my dad's motivation or capability of doing this, so my general goal is simply:

Get my dad into the world of computers, and get him on the road to programming.

I strongly believe that once I get him through the fundamentals, his drive and reading skill will keep him going on this own.

So I'm asking you all: where should I start with all this? And what are the best resources out there? Should I get him to start Linux instead of Windows? Is C++ a bad idea?

Remember, he needs to (IMO) learn computers first, and then get that first grasp (the "Hello world" experience) of programming.

For money's sake and at top preference, I'd like free online resources that he can read, but by all means any good suggestions in print or paid-for-online are welcome (that I could possibly look into later to purchase).

And also, I intend to start him off with C++ (no Python, Java, etc.), because I know it the best and will be able to help him along the way with code. (I have minimal knowledge right now in other languages).

Edit: I'm getting a lot of persistent suggestions to use Python. The only reason I wanted to do C++ is that I KNOW it and can be THERE when my dad needs help. My VERY FIRST exposure to programming ever was Java. I learned Java, and I got good at it. I open to other suggestions, but please provide an effective application of your suggestions.

EDIT #2: I understand my approach/thinking/knowledge could be lacking here. I'm a sophomore level undergraduate CS major. If you don't agree with anything in my post, tell me why - give me ideas, information - that's why I'm asking in the first place. To narrow down my general goal to specific reachable goals.

答:
I think your dad's interest in C++ is definitely neat but it would not be my choice for a first programming language -- unless he has a very specific requirement that he is interested in meeting. (Even then, learning C++ after learning another, simpler, language might still be far easier.)

There's a handful of things that are important for programming:

The ability to solve abstract problems

The ability to decompose problems into small enough pieces for problem solving

The ability to build solutions iteratively and in small enough pieces that forward progress is possible

The syntax and semantics of specific languages.

In many ways, the syntax and semantics of specific languages is near the end of the skills necessary for programming. After all, if you're close to right, most compilers will tell you what mistake you've made -- though it takes experience to decode what specifically compilers are saying.

So, I'd suggest that your father tackle a far simpler programming language on the first go: Ruby, Python, C, C#, Haskell, etc. (Haskell is definitely difficult for people who've programmed only imperative languages, but I'd be curious to know if complete novices suffer the same "fish-out-of-water" feeling.)

Sticking with a simpler language up front means that your dad will have more success earlier, and will find it easier to "play". The interactive REPL loop of many languages is an excellent place to learn.

Once your dad is familiar with functions, classes, objects, methods, then the minutiae and nuances of C++ won't feel so overwhelming. Heck, even starting with C would be easier: it isn't forgiving, but there are fewer confusing features to worry about.

You're curious about Linux vs Windows; I'm not sure the distinction matters much. If he's already familiar with one or the other environment, switching is just another hurdle. If he knows neither, I'd suggest Linux, but mainly because installing good tools is ridiculously easy: apt-get install <foo> works on most distributions, and the distributions that don't support apt often provide something similar. A minute later, your neat new package is installed, often faster than it would take me to find a reliable download source for precompiled Windows binaries that doesn't reek of Trojan horses.


答:
First off, even if you do personally know C++ well, it's a horrible, horrible first language for beginners, and I cannot recommend strongly enough to keep him as far away from it as possible if he wants to successfully learn to write code.  Learning programming is not about a language, it's about learning to express abstract requirements in formal logic.  C++ makes that difficult to focus on because you're constantly tripping over language-specific issues.

If he wants to learn to express ideas in formal logic, go for something that makes that simple.  My choices would be Pascal (for application-level development) or Python (for script-level work) because they're both designed with being intuitive and easy to learn as core priorities.  Once he actually knows the principles of how to write code, then if he really cares about C++ specifically, he can pick it up.

For the same reason, don't start him on Linux instead of Windows, because then he has two problems to focus on: learning Linux and learning coding, at the same time!  Keep the distractions to a minimum.

As for actual programming resources, it's easy enough to find tutorials online, but I've found that the best way to learn to program is by programming.  Find something that you'd like to do, and then start figuring out how to do it.

Several years ago, I saw a game and I thought, "I could do this, and I could do it better."  So I fired up Delphi and started figuring out the principles involved.  I'm still learning new stuff from that personal project, and along the way, I've become a really good coder!  So try that; ask your dad what he'd like to do if he could program--and make sure it's possible, and reasonably small in scope since he has no experience yet--and then sit down with him and start figuring out with him how to do it.

And if he has any questions, get him a StackOverflow account. :)

Title: How to introduce a computer illiterate 50-year old to programming

Body:
The other day my dad asked me a question that I would have never expected from him.

"How can I learn C++?"

My dad is turning 56 this year and computers are a distant concept for him. He doesn't know how to use a phone very well besides calling numbers (no speed dial or contacts); though he has started to learn computers a little better - to the point that he knows how to open the internet (in Windows) and browse around (and has successfully completed several job applications entirely on his own online, of which he was offered positions too). But still, these are too narrow-windowed experiences to mean much, really.

While he may not have the background, my dad knows how to read. And I mean reading as a skill, not just an ability. He has little to no college education (financial problems, family, etc.) and was fortunate enough to finish high school, but still taught himself to become a master electrician and has been one for almost 30 years now. He did the same with guitar, learning to play at a very professional level and has been praised for his skill. In high school, he picked up a weight lifting book - and was the only person in his high school at the time to qualify officially as an "athlete" by national standards.

In all cases, he just needed something to read. Something to teach him. He absorbs information like a sponge.

I have no doubt in my dad's motivation or capability of doing this, so my general goal is simply:

Get my dad into the world of computers, and get him on the road to programming.

I strongly believe that once I get him through the fundamentals, his drive and reading skill will keep him going on this own.

So I'm asking you all: where should I start with all this? And what are the best resources out there? Should I get him to start Linux instead of Windows? Is C++ a bad idea?

Remember, he needs to (IMO) learn computers first, and then get that first grasp (the "Hello world" experience) of programming.

For money's sake and at top preference, I'd like free online resources that he can read, but by all means any good suggestions in print or paid-for-online are welcome (that I could possibly look into later to purchase).

And also, I intend to start him off with C++ (no Python, Java, etc.), because I know it the best and will be able to help him along the way with code. (I have minimal knowledge right now in other languages).

Edit: I'm getting a lot of persistent suggestions to use Python. The only reason I wanted to do C++ is that I KNOW it and can be THERE when my dad needs help. My VERY FIRST exposure to programming ever was Java. I learned Java, and I got good at it. I open to other suggestions, but please provide an effective application of your suggestions.

EDIT #2: I understand my approach/thinking/knowledge could be lacking here. I'm a sophomore level undergraduate CS major. If you don't agree with anything in my post, tell me why - give me ideas, information - that's why I'm asking in the first place. To narrow down my general goal to specific reachable goals.


答:
Microkernels are the future

He got that wrong, seems everything is converging into using hybrid kernels. Linux formally still is monolithic, but adding stuff like FUSE etc. make it look bit hybrid too.

x86 will die out and RISC architectures will dominate the market

Ok, so x86 didn't die out. But doesn't RISC dominate the market? Billions of smartphones using ARM, all gaming consoles using RISC processors, most network hardware using MIPS processors.

Besides, by early-2000s RISC and CISC have converged so much, that there were no clear cut differences in internal design. Modern x86 processors basically are internally RISC with CISC interface.

(5 years from then) everyone will be running a free GNU OS

If by GNU OS he meant GNU Hurd, then indeed a totally failed prediction.  What people do massively use is Android. Android is Linux, however it is not GNU, as it doesn't use GNU libc. Instead it uses Google's own Bionic. And the market share of standard desktop Linux is still below 2%. But did he really mean consumer PCs? On server market Linux absolutely dominates with 70-90% of share depending on the segment.


问:
What is the objective of unit testing?

Possible Duplicate:

  Is unit testing or test-driven development worthwhile?

I've been working with C# for the last 2 years, and I've never done any unit testing. I just need to know what the objective of unit testing is. What kind of results do we expect from unit testing? Is code quality checked by unit testing? In my view, unit testing is the job of testers; if that is true, then as a developer why would I need to write test code if the tester does the unit testing? Why should I write extra code for testing? Do I need to maintain a separate copy of a project for unit testing?

答:
Avoiding Regressions

(had to state that out loud and clear)

Regressions are so incredibly relevant it's unbelievable most schools still don't bother even mentioning them.

Here, read the Wikipedia article on Regression Testing. It's a structured introduction to the topic and highlights both Unit and Functional tests. (a distinction many tutorials overlook, but then, functional tests, don't usually need frameworks or syntax sugar)

Regressions in code obviously don't go away magically with testing, but the combined powers of VCS and Unit Testing help catch them early on and act upon them with viking fury.

Title: What is the objective of unit testing?


问:
Is it a good approach to rely on 3rd party software ( not library )?
We have program( written in VB ) using a call to a winzip program or 7zip command line tool to zip some files. Once I accidentally uninstall the winzip on my computer and making one of our program( created by the programmer already left ) crashed. So we cannot uninstall the winzip program.

Now we am writing another program with java + windows batch file. And I've come to a point which I need to make a decision between 1) using a call to external tool ( for example 7z ) for gzip in windows batch file, 2) or I make a java program to gzip the file.

Obviously a external tool such as 7z is convenient and we can avoid some extra coding with java. On the contrary, if 7z is uninstalled accidentally, our program will crash. What do you think?

答: To save your program from Crash, you have to add your necessary dll from that application. But i warn you that it should not break any liecense agreement</p>


答: In the case of zipping capabilities in a Java program, you shouldn't need to delegate to an external program like winzip or 7zip. Have you looked into the standard Java zipping functionality? The ZipOutputStream in partcular should be able to do what you need. I haven't used it to create zips (or gzips) myself but I would expect it to be easier than calling an external program, especially when it comes to error handling.</p>

Title: Is it a good approach to rely on 3rd party software ( not library )?

Body:
We have program( written in VB ) using a call to a winzip program or 7zip command line tool to zip some files. Once I accidentally uninstall the winzip on my computer and making one of our program( created by the programmer already left ) crashed. So we cannot uninstall the winzip program.

Now we am writing another program with java + windows batch file. And I've come to a point which I need to make a decision between 1) using a call to external tool ( for example 7z ) for gzip in windows batch file, 2) or I make a java program to gzip the file.

Obviously a external tool such as 7z is convenient and we can avoid some extra coding with java. On the contrary, if 7z is uninstalled accidentally, our program will crash. What do you think?


问:
How do you QA and release software quickly with a large team?
My work used to be a smaller team. We had less than 13 devs for a while. We are now growing rapidly, and are over 20 with plans to be over 30 in a few months.

Our process for QA'ing and releasing each build is no longer working. We currently have everyone develop the new code, and stick it onto a staging environment. A few days before our weekly release, we would freeze the staging environment and QA everything. By our normal release time, everything was usually deemed acceptable and pushed out the door to the main site.

We reached a point where our code got too big so we could no longer regress the entire site each week in QA. We were ok with that, we just made a list of everything important and only covered that and the new stuff. Now we are reaching a point where all the new stuff each week is becoming too big and too unstable. Our staging environment is really buggy week after week, and we are usually 1-2 hours behind the normal release time.

As the team is growing further, we are going to drown with this same process. We are re-evaluating everything, and I personally am looking for suggestions / success stories. Many companies have been where before and progressed beyond, we need to do the same

答:
I currently work on a ~30 person development team that frequently releases a very large codebase of significant complexity, so some of our experiences may be of interest.

When it came time to setup our test approach, we initially split off a team of 4 people to setup the "harness", the core structure of the code supporting the automation of our tests. All tests are written in Cucumber, and the step definitions are relatively light, mostly making a couple calls into the harness that does the real work.

Once the harness was to the point that the team was able to write tests, about half of our entire group transition over to writing tests. The exact balance onbviously depends on the level of testing needed for your own project. Some things we learned early on:

Create a couple tests and then loop back and harmonize them. Start building a standard so that new tests match the style of what is already in place. We ended up doing this later on, and had to go back and standardize what had been written so far.

Code review feature files. Aggresively look for step definition duplication, when people go head down writing these things they start missing that someone already wrote the exact same thing.

Make sure you are testing the right thing. For example, if submitting a form should do X, make sure the test is about submitting the form and not about clicking "Submit". The step definition may click the button, but the feature file shouldn't have to change if the name of a button does.

If a test is likely to change because of a change in implementation without a change in functionality, then the test probably will break down the road. This mostly goes with 3.

We got to the point that running all of our tests from start to finish took an obscene amount of time. If you think you may get to the same point, think early about automating test environment setup so that you can easily run tests across multiple machines. We can deploy our entire production system to a clean host in under a minute, which allows us to scale up testing in burst very easily.

Whenever we prepare to do a release we cut a build, and then run it through these tests. We review any failures, and determine if they need to be fixed before delivery. If they do, fix and repeat. The entire process from first build to delivery usually takes under a week.

We have just recently gotten to the point that we are integrating together our Dev and QA teams. Now, any feature we are going to develop has a feature file written before anything else. Then we develop the code for the feature. And right after that the feature file is run. This only becomes possible once you have enough people on your team that understand BDD/your harness that they can help the rest of the team produce good tests.

OwnerDisplayName: sadadasd


问:
Where Can I List My Opensource Project?

Possible Duplicate:

  How can I get the word out about a new (open-source) library I've developed?

I have hosted my latest project, a JVM-based MIDI processor/API called Mjdj MIDI Morph, on Github (here and here). Now I need to bring some interest to it, even if it's negative interest (so I can improve it). I've looked up open source list on Google and end up with such things as this page on Wikipedia, which makes it quite clear that they don't want your project if it's new. Where should I list my project? Short of adwords and talking it up in forums and trade shows, where should I submit my URLs?

答: Get it announced on Freshmeat Freecode (no longer accepting updates as of 2014-06-18).  Also, remember to get to a usable state or people will only use it once and keep that impression forever...

Title: Where Can I List My Opensource Project?


问:
test for graduate software developer role?
I'm looking for tests that are suitable for a graduate software developer role, mainly tests that are about reviewing code and finding faults and etc, multiple choice or otherwise.preferably code written in c#.

I have a test coming up soon and want to prepare before hand.

答:
A graduate software developer has to be proficient at applying the right algorithm and unit testing as well.

Here is a good online resource available that may help you in this regard:

Programming Interviews Exposed

You can make up your own MCQs, depending upon what area of programming or development you'd like to concentrate more. Here is one more link that may help you as well:

Programmer Competency Matrix

It depnds upon what background, qualification and the type of candidate you are seeking for. Remember, that there are 2 approaches people usually follow as a software developer.

Approach 1 : Mastering problem solving

People who follow this approach focuses on problem solving and then determines how to translate their worked out solution into the required programming language. Their concentration is more on system analysis and design than technical aspects of coding and programming language. They can derive abstractions from the given problem and implement the solution successfully in the given programming language with little efforts.They can fully apprehend the phases of the SDLC very well and do realize the support and maintenance aspects of the solution as well. Such people are always here to stay in the software development industry and climb up in their career in 5-8 years time.

Approach 2: Mastering the programming language

People following this approach are geeks who concentrate more on the coding and technical aspects of the language then understanding the problem domain and working out it's solution. They are more or less like problem translators or interpreters. They work 9 to 5 just to translate a given solution task to the syntax of the programming language. They have to work for 10 years or probably more, depending upon their job role and learning capacity. Either such people get tired very soon or they struggle to become a problem solver quite late in their career.

Wish you best of luck!


问:
Does MVC apply only to web
It is almost and instantaneous whenever I talk to developers about Model View Controller (MVC) they say you make a request to a url the server builds a entity (MODEL) and provides you with visual representation of that model.

So does this mean MVC is only for the web or have I been meeting people who are just developers who employ MVC for writing web applications?

Are there usages for MVC on desktop style applications?

I for one am new to paradigm and would like to know of any super-set to MVC

答:
So there is a lot of different design patterns in this area.

Model View Presenter (mvp)

Model View View Presenter (mvvp)

Model View Controller

Model 2

and so on. Over the years these have been intertwined, mashed together, changed and applied in a wide variety of contexts.
The important bit here, is that the MVC design pattern from 1977 has changed quite a lot, and is no longer the design pattern used by serverside web frameworks. As an example in the original smalltalk implementation the Model would observe the view for changes, which is no longer the case as the serverside simply can't observe html elements in the users browser. Instead if the view changes, the view will send a request to the controller which will then update the view. Again the original MVC implementation is not followed, as an update to the model would imply that all views dependent on the model would be updated.

The modern web frameworks follows a simple three tier architecture also known as a Model 2 architecture.

There are of course examples of real MVC architectures on the web, but these are often client side only, connected to a server which follows the Model 2 architecture, as the views are xml and json, and not observed for changes.
Examples of client side pure mvc architectures are Sencha Touch and Sproutcore.

If you have MVC in the browser, mvc like on the server, and mvc like as the data layer, you have a hierarchial mvc implementation.

Note. I've only talked about web frameworks, other implementations of MVC such as java swing and Flex has other implementation differences.

Title: Does MVC apply only to web


问:
Not getting paid for hours you've worked?
So I was reading from a previous thread about App vs Game Development:

If it was for you to chose Game Development vs Application Development, which will you chose?

Which brought me to this site: EA: The Human Story

A lot of it talked about developers working something like 85 hours a week, and not getting paid overtime, or anything. Just getting paid for the 40 hours. Is this normal for most software companies? I mean where I work I'm only an entry level guy but I get overtime, and anything over 40 hours is considered this. But it got me thinking "Holy crap" I could never do that. My FREE time is important to me. But is this commonplace in most software companies? Or is more a rarity to certain types (game development, etc)?

Because it got me scared!

Like I understand having to put some extra hours in for a project... but like 80! that's ridiculous.

答:
I am working fulltime in the third company now - PHP - and I always got overhours paid or compensated with free time. In one company I worked, you got +25% for an over hour. It is always encouraged to just compensate yourself by working less on other days.

I would personally never ever consider working for a company that expects overhours without compansating those in an at least proportional manner. That is just very very very unhealthy. Only exception I would make if the salary was suberbial and by that kinda paying for overhours indirectly.

I record my worktime down to the quarter hour. And in my opinion that is fair for the employer as well as for the employee.


问:
What should you include in a development approach document?
I'm in the middle of co-producing a "development approach" document for off-shore resources as they ramp up onto our project.

The most recent (similar) document our company has used is over 80 pages, and that does not include coding standards/conventions documents.

My concern is that this document will not be consumable and will therefore fail.

What should be in a development approach document?
Are there any decent guidelines on this topic?

EDIT: The development approach document should detail the practices and techniques that will be used by software developers while software is designed, built, and tested.

答:
An approach document is a 'Neither here nor there' document. This is a document generally asked by Project Managers (Vendor Managers) of Business organisations from Project Managers (Software Development Managers) of Software Application Development Organisations.

The purpose of this document varies based on the needs of the Business Org PM.

Can contain hw architecture, system functions, communication plans, configuration plans, resource loading plans, technology stack, application architecture and so on..

again, the above list is variable based on the needs .. :)

am yet to see formal literature on such a document. if there are any by the standard authors Pressman etc. do share..

or am i missing something.


答: It's very common in investment banks. Some people in certain departments (notable M&A == Mergers & Acquisitions) put in ridiculous hours, like over 100h/week. On trading floors, the norm is 9-11h day (including lunch break), but you almost never work on weekends. You don't get any overtime, but the salary is high enough so that people don't complain.</p>

Title: Not getting paid for hours you've worked?

Body:
So I was reading from a previous thread about App vs Game Development:

If it was for you to chose Game Development vs Application Development, which will you chose?

Which brought me to this site: EA: The Human Story

A lot of it talked about developers working something like 85 hours a week, and not getting paid overtime, or anything. Just getting paid for the 40 hours. Is this normal for most software companies? I mean where I work I'm only an entry level guy but I get overtime, and anything over 40 hours is considered this. But it got me thinking "Holy crap" I could never do that. My FREE time is important to me. But is this commonplace in most software companies? Or is more a rarity to certain types (game development, etc)?

Because it got me scared!

Like I understand having to put some extra hours in for a project... but like 80! that's ridiculous.


问:
how should I design Objects around this business requirement?
This is the business requirement:

"
A Holiday Package (e.g. New York NY Holiday Package) can be offered in different ways based on the Origin city:

From New Delhi to NY

From Bombay to NY

NY itself ( Land package )

(Bold implies default selection)

a. and b. User can fly from either New Delhi or Bombay to NY.

c. NY is a Land package, where a user can reach NY by himself and is a standalone holidayPackage.
"

Let's say I have a class that represents HolidayPackage, Destination (aka City).

```<code>public class HolidayPackage{
    Destination holidayCity;
    ArrayList<BaseHolidayPackageVariant> variants;
    BaseHolidayPackageVariant defaultVariant;
}

public abstract class BaseHolidayPackageVariant {
    private Integer variantId;
    private HolidayPackage holidayPackage;
    private String holidayPackageType;
}

public class LandHolidayPackageVariant extends BaseHolidayPackageVariant{
}

public class FlightHolidayPackageVariant extends BaseHolidayPackageVariant{
    private Destination originCity;
}
</code>```

What data structure/objects should I design to support:

options

a default within those options

Sidenote: A HolidayPackage can also be offered in different ways based on Hotel selections. I'd like to follow a design which I can leverage to support that use case in the future.

This is the backend design I have in mind.

答:
Judging from the proposed database schema, you could have a class called HolidayPackage with attributes of type Hotel, City, and PackageVersion.

PackageVersion would be a superclass of LandPackageVersion and FlightPackageVersion.  It is declared as the generic PackageVersion so that polymorphism or dependency injection can be used to populate it with the appropriate subclass.

```<code>public Class HolidayPackage{

    Hotel hotel;
    City city;
    PackageVersion package;  //could be an instance of LandPackageVersion or FlightPackageVersion
    .
    .
    .
</code>```

Edit

OK, now that you have edited your question to show your class structure, I can see you already have it organized how I was recommending above.  So this should work fine as long as you have methods that tell you information about each BaseHolidayPackageVariant in the variants ArrayList, such as whether or not there is a flight associated with it.

Oversimplified example:

```<code>public abstract class BaseHolidayPackageVariant {

    public boolean hasFlight(){}
}

public class LandHolidayPackageVariant extends BaseHolidayPackageVariant{

    public boolean hasFlight(){
        return false;
    }
}

public class FlightHolidayPackageVariant extends BaseHolidayPackageVariant{

    public boolean hasFlight(){
        return true;
    }
}
</code>```

So, at runtime, you don't really need to use instanceOf() because you'll know everything you need to know about the Objects using these descriptive methods.

Body:
Judging from the proposed database schema, you could have a class called HolidayPackage with attributes of type Hotel, City, and PackageVersion.

PackageVersion would be a superclass of LandPackageVersion and FlightPackageVersion.  It is declared as the generic PackageVersion so that polymorphism or dependency injection can be used to populate it with the appropriate subclass.

public Class HolidayPackage{

    Hotel hotel;
    City city;
    PackageVersion package;  //could be an instance of LandPackageVersion or FlightPackageVersion
    .
    .
    .

Edit

OK, now that you have edited your question to show your class structure, I can see you already have it organized how I was recommending above.  So this should work fine as long as you have methods that tell you information about each BaseHolidayPackageVariant in the variants ArrayList, such as whether or not there is a flight associated with it.

Oversimplified example:

public abstract class BaseHolidayPackageVariant {

    public boolean hasFlight(){}
}

public class LandHolidayPackageVariant extends BaseHolidayPackageVariant{

    public boolean hasFlight(){
        return false;
    }
}

public class FlightHolidayPackageVariant extends BaseHolidayPackageVariant{

    public boolean hasFlight(){
        return true;
    }
}

So, at runtime, you don't really need to use instanceOf() because you'll know everything you need to know about the Objects using these descriptive methods.


答: If your program crashes in the absence of 7zip, you have to add some very basic thing every program should have: it is called "error handling". For example, if 7zip is missing at the place where you expect it, your program could display an error message telling the user what went wrong and that you expect 7zip to be installed. And (as far as I known), current license of 7zip is mostly LGPL, so redistributing it (without modification) should be no probem (but IANAL).</p>


问:
Where, in an object oriented system should you, if at all, choose (C-style) structs over classes?
C and most likely many other languages provide a struct keyword for creating structures (or something in a similar fashion). These are (at least in C), from a simplified point of view like classes, but without polymorphism, inheritance, methods, and so on.

Think of an object-oriented (or multi paradigm) language with C-style structs. Where would you choose them over classes? Now, I don't believe they are to be used with OOP as classes seem to replace their purposes, but I wonder if there are situations where they could be preferred over classes in otherwise object-oriented programs and in what kind of situations. Are there such situations?

答:
The accepted answer is good. I'd just like to add....

Sometimes it's better to put a method inside a class. Other times it's better to have an external function where the struct/class is passed in as a parameter (even if you are doing OOP style).

example of when to put a method inside the class: Rectangle.CaclulateArea()

example of when to put a function outside the class: Canvas.Draw(Rectangle rect)

you could put Draw() inside the Rectangle and it would work. But drawing is a tier dependent operation. You wouldn't draw on the server side, but on the client side. Draw() would not make sense to even exist on the server. However "CalculateArea()" is independent of tier and is a true attribute of the rectangle, so it's better to include it as a member method.


答: I think, programming is creative work. It don't depend on number of hours you work. A skilled programmer, can complete a 'programming task' in 1 hour, where as an unskilled one  don't complete it in 1 day also. </p>


问:
How to make hardware sizing sheet?
We build some software platform, and now we need to make hardware sizing sheet for the server-side piece of this software. So, I should prepare some mathematical model that, for example, given the number of concurrent users, can predict the number of physical servers or storage capacity or network bandwidth. How to make such model?</p>

答:
A "purely mathematical" approach is unlikely to be very accurate.  One of the basic questions to ask when optimising software for performance is "have you measured it"?

My advice would be to perform some stress testing of your software.  Do this in a carefully controlled way, and observe the behaviour of the system while it's under different levels of stress.  This information, combined with your inside knowledge of the system itself, should allow you to come up with some educated guesses about the way your system will perform with different hardware and different loads.  I would advise against trying to extrapolate to hardware that varies wildly from your test setup - it's one thing to predict what will happen if you go from two cores to four, but will that scale to 64 cores, or make efficient use of hundreds of GB or RAM?  I would stay away from wild guesses like that.

Title: How to make hardware sizing sheet?


问:
How to store a list of Objects that might change in future?
I have set of Objects of the same class which have different values of their attributes.
and I need to find the best match from a function under given scenarios out of these objects.

In future these objects might increase as well.

Quite similar to the way we have Color class in awt.
we have some static color objects in the class with diff rgb values.
But in my case say, I need to chose the suitable color out of these static ones based on certain criteria.

So should I keep them in an arrayList or enum or keep them as static vars as in case of Colors.
because I will need to parse through all of them and decide upon the best match.
so I need them in some sort of collection.
But in future if I need to add another type I will have to modify the class and add another list.add(object) call for this one and then it will violate the open-close principle.
How should I go about it ?

EDIT:
To be more precise I have a roughly 7-8 branches of  restaurants which wont increase that much..may be by 3-4 in few years and I need a function that will return the nearest Restaurant satisfying few other criteria.

and For that I need to parse through all of them to decide which one suits the customer the most.

答: Store the stores on disk. I would recommend using a database but for the small amount of data xml would do fine as well. On application start up read this list into a collection. You wouldn't need to create constants for each because you will just be querying the list when you need a store. This will keep you from having to update your code just to add a new store. Also since you are computing distances you will need a list of all the zip codes and their corresponding latitude and longitude so that you can compute the distance between two zipcodes. This could also be stored on disk and most likely will need updating more frequently than your store list. In addition, you could create an admin console that will let you add new stores and update zip codes without having to manually write to the storage mechanism you have chosen.</p>


答:
Based on your current implementation it sounds like the holiday package should contain a travel mechanism (air, land, from, to), a place to stay, and also what you are currently calling the base package. Your options should be a list of holiday packages that contain different combinations of the travel, hotel, and base package properties.

If the presented packages are supposed to have a default you can simply add a integer value that is the sort/rank index and then decide that the default is the one with the lowest or highest number.

Title: how should I design Objects around this business requirement?

Body:
This is the business requirement:

"
A Holiday Package (e.g. New York NY Holiday Package) can be offered in different ways based on the Origin city:

From New Delhi to NY

From Bombay to NY

NY itself ( Land package )

(Bold implies default selection)

a. and b. User can fly from either New Delhi or Bombay to NY.

c. NY is a Land package, where a user can reach NY by himself and is a standalone holidayPackage.
"

Let's say I have a class that represents HolidayPackage, Destination (aka City).

```<code>public class HolidayPackage{
    Destination holidayCity;
    ArrayList<BaseHolidayPackageVariant> variants;
    BaseHolidayPackageVariant defaultVariant;
}

public abstract class BaseHolidayPackageVariant {
    private Integer variantId;
    private HolidayPackage holidayPackage;
    private String holidayPackageType;
}

public class LandHolidayPackageVariant extends BaseHolidayPackageVariant{
}

public class FlightHolidayPackageVariant extends BaseHolidayPackageVariant{
    private Destination originCity;
}
</code>```

What data structure/objects should I design to support:

options

a default within those options

Sidenote: A HolidayPackage can also be offered in different ways based on Hotel selections. I'd like to follow a design which I can leverage to support that use case in the future.

This is the backend design I have in mind.


问:
What exactly is the build number in MAJOR.MINOR.BUILDNUMBER.REVISION
What I think about Build Numbers is that whenever a new nightly build is created, a new BUILDNUMBER is generated and assigned to that build. So for my 7.0 version application the nightly builds will be 7.0.1, 7.0.2 and so on. Is it so? Then what is the use of a REVISION after the build number? Or is the REVISION part being incremented after each nightly build? I am a little confused here... do we refer to each nightly build as a BUILD?

The format is mentioned here: AssemblyVersion - MSDN

答: Like jkohlhepp, we use the third part of the version to show the revision number in SubVersion and the fourth to show the build number from our continuous integration server (Jenkins for us). This gives us a several benefits - having the version number set by our CI server removes a manual step that could otherwise be accidentally missed; it's easy to check that a developer hasn't done a cheeky release from their development PC (which would result in these numbers being zero); and it allows us to tie any piece of software back to both the code that it was generated from and the CI job that built it, just by looking at the version number - which we occasionally find very useful.


问:
Is this kind of Design by Contract useless?
I've just started informatics university and I'm attending a programming course about C(++). The programming professor prefers to connect every topic with a type of programming design that is similar to Design by Contract. Basically, what he asks us to do is to write every exercise with comments that denote the pre-condition, post-condition, and invariants that should prove the correctness of each program we write.

But this doesn't make any sense to me. Maybe writing down your thoughts prevent you from making some mistakes, but if this is all an abstract thing, then if your program intuition is wrong, you'll write your program wrong, and then you'll also write pre and post conditions wrong. In the end, you'll be convinced that a wrong program might actually be correct.

I had some programming experience before this course and I found myself comfortably with just writing a program and unit testing it. It takes less time to accomplish and is less "abstract" than just thinking about what every single piece of your program should do in every case (which is kinda like mentally testing it).

Finally, determining the pre and post conditions takes me about 80% of the total time of the exercises. It's harder to think about putting down this pre and post correct than to write the program itself.

Am I right in thinking that working with pre-conditions, post-conditions, and invariants aren't worth anything? Should I convince myself that this method is right?

答: The given/when/then scenario of unit testing contains the pre-conditions, post-conditions, and invariants of your program. If you are writing your tests correctly you are already documenting this. and simply need to put the test code in to words in your comments to appease the professor. </p>


问:
How do you quantify competency in terms of time (years)?
While looking for a job via agencies some time ago, I kept having questions from the recuitment agents or in the application forms like:

How many years of experience do you have in:

Oracle

ASP.NET

J2EE etc etc etc....

At first I answered faithfully... 5yrs, 7yrs, 2 yrs, none, few months etc etc..

Then I thought; I can be doing something shallow for 7 years and not being competent at it simply because I am just doing a minor support for a legacy system running SQL2000 which requires 10 days of my time for the past 7 years. Eventualy I declined to answers such questions.

I wonder why do they ask these questions anymore. Anyone who just graduated with a computer science can claim 3 to 4 years experience in anything they 'touched' in the cirriculum, which to me can be equivalent to zero or 10 years depending how you look at it.

It might hold true decades ago where programmers and IT skills are of very different nature. I might be wrong but I really doubt 'time' or 'years' are a good gauge of competency or experience anymore.

Any opinion/rebuttal are welcome!

答:
You have raised a very good question.

You need to convey several pieces of information:

How long have you being using the technology.

What skill level you feel you are at.

When you last used the technology.

Unfortunately most recruiters just look for a single figure so that they can rank candidates and only send those that hit a "score" along to the prospective employer.

You need to say something like:

1997 - 2004, developed 3D toolset and desktop applications using C and C++/MFC with Visual Studio 6.0

This conveys all the above information, but doesn't fit in most forms.


答:
This isn't strictly known as Design By Contract, DBC is a marketing term used by Bertrand Meyers' company and the concept of using pre-conditions, post-conditions and invariants to develop a program was being used by Dijkstra while he was using structured programming.

For larger programs or for more challenging algorithms it is highly useful to be aware of the pre-conditions, post conditions and invariants. They can guide in writing the program and they help make your thinking much clearer.

Title: Is this kind of Design by Contract useless?

Body:
I've just started informatics university and I'm attending a programming course about C(++). The programming professor prefers to connect every topic with a type of programming design that is similar to Design by Contract. Basically, what he asks us to do is to write every exercise with comments that denote the pre-condition, post-condition, and invariants that should prove the correctness of each program we write.

But this doesn't make any sense to me. Maybe writing down your thoughts prevent you from making some mistakes, but if this is all an abstract thing, then if your program intuition is wrong, you'll write your program wrong, and then you'll also write pre and post conditions wrong. In the end, you'll be convinced that a wrong program might actually be correct.

I had some programming experience before this course and I found myself comfortably with just writing a program and unit testing it. It takes less time to accomplish and is less "abstract" than just thinking about what every single piece of your program should do in every case (which is kinda like mentally testing it).

Finally, determining the pre and post conditions takes me about 80% of the total time of the exercises. It's harder to think about putting down this pre and post correct than to write the program itself.

Am I right in thinking that working with pre-conditions, post-conditions, and invariants aren't worth anything? Should I convince myself that this method is right?


问:
What is the most effective way to add functionality to unfamiliar, structurally unsound code?
This is probably something everyone has to face during the development sooner or later.

You have an existing code written by someone else, and you have to extend it to work under new requirements.

Sometimes it's simple, but sometimes the modules have medium to high coupling and medium to low cohesion, so the moment you start touching anything, everything breaks. And you don't feel that it's fixed correctly when you get the new and old scenarios working again.

One approach would be to write tests, but in reality, in all cases I've seen, that was pretty much impossible (reliance on GUI, missing specifications, threading, complex dependencies and hierarchies, deadlines, etc).

So everything sort of falls back to good ol' cowboy coding approach. But I refuse to believe there is no other systematic way that would make everything easier.

Does anyone know a better approach, or the name of the methodology that should be used in such cases?

答:
Write as much documentation as necessary to explain the current code. Once you're sure you understand the logic of it, then you may be ready to change it. Document whatever you're going to add and make sure that you cover all cases.

Write regression tests. It doesn't matter if you manually test or run the tests automatically, you need to preserve the original functionality and regression tests help with that.

If there's not enough specs, start bugging people for more information and write it down.

Write up a plan for changing the code and break it out into different phases.


问:
Is dependency injection essential for unit testing?
Is using dependency injection (DI) essential for unit testing?

I can't think of another alternative for isolating code so it can be tested. Also, all the examples I have ever seen use this pattern. Is that because it is the only viable option or are there other alternatives?

答:
DI makes unit testing much easier. But you can still write unit tests without DI. Lots of unit tests have been written already before DI became widespread. (Of course, some of these used techniques identical or very similar to DI without knowing it has a fancy name :-)

I myself have used e.g. interfaces and factories a lot before learning about DI. The actual factory class name may have been read from a config file, or passed to the SUT as an argument.

Another approach is using singletons (or globally accessible data in general). Yes, I know it is not recommended by many (including myself) in general. Still it may be viable in specific situations, especially if the singleton contains static configuration data which is not test case specific, but differs between production and test environment. Of course it has its known problems, so DI is superior if you can use it. But often (e.g. in legacy systems) you can't.

Talking of which, Working Effectively With Legacy Code describes a lot of tricks to get legacy code covered by tests. Many of these are not nice, and aren't meant as a long term solution. But they allow you to create the first valuable unit tests to an otherwise untestable system... which enables you to start refactoring, and eventually (among others) introduce DI.


答:
Depending on the technologies that you're using, you can isolate dependencies without using DI.  For instance, in the .NET world, Moles allows you to isolate dependencies without the DI pattern.

That said, I believe these isolation frameworks are written and intended for situations in your code with external dependencies (filesystem, database, etc).  That is, the fact that one can do this doesn't mean he or she should.

Dependency injection allows unit testing, but it also allow modification of an object's behavior without altering the code of that object (open/closed principle).  So, it isn't just testable code, but flexible code that results.  I've generally found that there is a heavy correlation between maintainable/flexible code and testable code.

Title: Is dependency injection essential for unit testing?

Body:
Is using dependency injection (DI) essential for unit testing?

I can't think of another alternative for isolating code so it can be tested. Also, all the examples I have ever seen use this pattern. Is that because it is the only viable option or are there other alternatives?


问:
Variable naming conventions?
I've just started using ReSharper (for C#) and I kind of like its code smells finder, it shows me some things about my writing that I meant to fix a long time ago (mainly variable naming conventions).

It caused me to reconsider some of my naming conventions for methods and instance variables. ReSharper suggests that instance variable be lower camel case and begin with an underscore. For a while I meant to make all my local variables lower camel case but is the underscore necessary? Do you find it comfortable? I don't like this convention but I also haven't tried it yet, what is you opinion of it?

The second thing it prompted me to re-evaluate is my naming conventions for GUI event handlers. I usually use the VS standard of ControlName_Action and my controls usually use hungarian notation (as a suffix, to help clarify in code what is visible to the user and what isn't when dealing with similarly named variable) so I end up with OK_btn_Click(), what is your opinion of that? Should I succumb to the ReSharper convention or there are other equally valid options?

答:
The two rules that you are asking about, underscore at the beginning of the private field names, and method names are generally regarded as the norm in C# development circles. By adapting to those conventions your code will be immediately more understandable to other developers because that is the frame of mind they are used to operating in.

The suffix of Label, RadioButton, etc. for your controls is generally regarded as the norm as well. Frequently multiple controls will exist for a single concept (e.g. a Label and a TextBox), and this suffix is quite useful. True Hungarian notation was abandoned long ago because it has been bastardized into something that does not express its original intent, which was context about the variable not what type, size, etc.

Title: Variable naming conventions?


答: Decoupling is essential for unit testing. DI is a great way to achieve decoupling.


答:
No, DI is not essential for unit testing, but it helps a lot.

You can use factories or locators and test as you would with DI (just not as elegant and would require more setup).

Also, Mock Objects would be important in legacy systems where many calls are delegated to functions instead of dependencies. (Mock Objects can also be extensively utilized in a proper setup as well)

There can be setups where testing is nearly impossible. But this is not based on whether or not dependency injection is used.


答:
For me, the big difference is whether there is a class-invariant or not.

Or in other words: am I free to change any field to any value at any point in time? If so, it's a struct; If not, it's a class.

The usual example of a struct is a 2D point, with just an X and Y member, that can have any value and are totally independent of each other. Public access is acceptable.

An example of a class is the combination of a pointer to a character array and a length field: the length depends on the value of the pointer, and thus it should not be a struct. The fields should be private, and access should go through setters and getters to ensure the class invariant.

Title: Where, in an object oriented system should you, if at all, choose (C-style) structs over classes?

Body:
C and most likely many other languages provide a struct keyword for creating structures (or something in a similar fashion). These are (at least in C), from a simplified point of view like classes, but without polymorphism, inheritance, methods, and so on.

Think of an object-oriented (or multi paradigm) language with C-style structs. Where would you choose them over classes? Now, I don't believe they are to be used with OOP as classes seem to replace their purposes, but I wonder if there are situations where they could be preferred over classes in otherwise object-oriented programs and in what kind of situations. Are there such situations?


答:
I like the underscores. You know at first glance that the variable is a class member and private.

Sure the IDE can tell you that when you hover the mouse over it, but the "first glance" can't be beat. You know what's a local variable, and whats a member variable with your eyes alone. No scrolling or mouse hovers required.

You can use the "this" keyword but _ is shorter for better horizontal scanability. Descriptive names are usually desired but when something is an established convention it's better to have 1 character. for example using the letter i as the index when looping through an array. Since it's an established convention that i is an index, you get the benefit of scanability without the drawback of wondering what "i" means.

Title: Variable naming conventions?

Body:
I've just started using ReSharper (for C#) and I kind of like its code smells finder, it shows me some things about my writing that I meant to fix a long time ago (mainly variable naming conventions).

It caused me to reconsider some of my naming conventions for methods and instance variables. ReSharper suggests that instance variable be lower camel case and begin with an underscore. For a while I meant to make all my local variables lower camel case but is the underscore necessary? Do you find it comfortable? I don't like this convention but I also haven't tried it yet, what is you opinion of it?

The second thing it prompted me to re-evaluate is my naming conventions for GUI event handlers. I usually use the VS standard of ControlName_Action and my controls usually use hungarian notation (as a suffix, to help clarify in code what is visible to the user and what isn't when dealing with similarly named variable) so I end up with OK_btn_Click(), what is your opinion of that? Should I succumb to the ReSharper convention or there are other equally valid options?


问:
Application layer vs domain layer?
I am reading Domain-Driven Design by Evans and I am at the part discussing the layered architecture. I just realized that application and domain layers are different and should be separate. In the project I am working on, they are kind of blended and I can't tell the difference until I read the book (and I can't say it's very clear to me now), really.

My questions, since both of them concerns the logic of the application and are supposed to be clean of technical and presentation aspects, what are the advantages of drawing a boundary these two?

答:
The point of Domain Driven Modelling is to separate the essential domain model out and have it exist without any dependencies on other layers and other application concerns.

This allows you to focus on the domain itself without distractions (such as coordinating between the UI and the persistence services).

Title: Application layer vs domain layer?


答:
The main reason for these boundaries is separation of concerns. The code that accesses the data store should only have to worry about accessing the data store. It should not be responsible for enforcing rules upon the data. Additionally the UI should be responsible for updating controls in the UI, getting values from user input and translating them to something that the domain layer can use, and nothing more. It should call operations provided by the domain layer to perform any needed actions (e.g. save this file). A web service that is called should be responsible for converting from the transmission medium to something the domain layer can use, and then call the domain layer (most tools do a lot of this work for you).

This separation, when implemented properly can afford you the capability to change parts of your code without affecting others. For example, maybe the sort order of a returned collection of objects needs to change. Since you know that the layer responsible for data manipulation (usually the business logic layer) handles this stuff, you can easily identify where the code needs to be changed. As well as not having to modify how it is retrieved from the data store, or any of the applications using the domain (the UI and web service from my example above).

The ultimate goal is to make your code as easy to maintain as possible.

As a side note, some things cannot be pigeon-holed into a specific layer of the domain (e.g. logging, validation, and  authorization). These items are commonly referred to as cross-cutting concerns, and in some cases can be treated as a layer that stands by itself that all the other layers can see and use.

Personally I think the layered approach is outdated, and that the service approach is better. You still have the stark line drawn in the sand as to who does what, but it doesn't force you to be as hierarchical. For example, a purchase order service, a billing service, and a shipping service, from the application perspective all of these services represent your domain, and the deferment of responsibility I described above is still valid in this context, it has just been altered such that your domain exists in multiple places, further utilizing the separation of concerns concept.

Title: Application layer vs domain layer?

Body:
I am reading Domain-Driven Design by Evans and I am at the part discussing the layered architecture. I just realized that application and domain layers are different and should be separate. In the project I am working on, they are kind of blended and I can't tell the difference until I read the book (and I can't say it's very clear to me now), really.

My questions, since both of them concerns the logic of the application and are supposed to be clean of technical and presentation aspects, what are the advantages of drawing a boundary these two?


答:
Taking from Martin Fowler's patterns of enterprise design, the most common layers are:

Presentation - these are views, presentation templates which
generate the interaction interface for your application (I am using
interaction in case your application is accessed by other systems
through web services or RMI so may not be a user interface). This
also includes controllers which decide how actions will be executed
and how.

Domain - this is where your business rules and logic resides, your
domain models are defined etc

Data Source - this is the data mapping layer (ORM) and data source
(database, file system etc)

How do you draw the boundaries between the three layers:

Do not put presentation specific logic within your models or domain objects

Do not put logic within your pages and controllers, i.e., logic to save objects to the database, create database connections etc, which will make your presentation layer brittle and difficult to test

Use an ORM which enables you to decouple your datasource access and actions from the model

Follow the thin controller - fat model paradigm, controllers are for controlling the process of execution not carrying it out, more at http://www.littlehart.net/atthekeyboard/2007/04/27/fat-models-skinny-controllers/ and http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model
model, view and controller,

Title: Application layer vs domain layer?


问:
How would you know if you've written readable and easily maintainable code?
How would one know if the code one has created is easily readable, understandable, and maintainable? Of course from the author's point of view, the code is readable and maintainable, because the author wrote it and edited it, to begin with. However, there must be an objective and quantifiable standard by which our profession can measure code.

These goals are met when one may do the following with the code without the expert advice of the original author:

It is possible to read the code and understand at a basic level the flow of logic.

It is possible to understand at a deeper level what the code is doing to include inputs, outputs, and algorithms.

Other developers can make meaningful changes to the original code such as bug fixes or refactoring.

One can write new code such as a class or module that leverages the original code.

How do we quantify or measure code quality so that we know it readable, understandable, and maintainable?

答:
Sometimes, the best way to know, is to come back to code you wrote six months ago and try and understand what it was written to do.

If you understand it quickly - it's readable.


答:
If your code follows the principles of SOLID and DRY and has a good set of unit tests around it, it is probably maintainable.

Is it readable? Read it. Do method and variable names make sense? Can you follow program logic without a problem? If the answer is yes, then the code is readable.

Title: How would you know if you've written readable and easily maintainable code?

Body:
How would one know if the code one has created is easily readable, understandable, and maintainable? Of course from the author's point of view, the code is readable and maintainable, because the author wrote it and edited it, to begin with. However, there must be an objective and quantifiable standard by which our profession can measure code.

These goals are met when one may do the following with the code without the expert advice of the original author:

It is possible to read the code and understand at a basic level the flow of logic.

It is possible to understand at a deeper level what the code is doing to include inputs, outputs, and algorithms.

Other developers can make meaningful changes to the original code such as bug fixes or refactoring.

One can write new code such as a class or module that leverages the original code.

How do we quantify or measure code quality so that we know it readable, understandable, and maintainable?


答:
I agree, this measure of competence is meaningless.  However, I am guessing that most recruiters do not know that.  They simply try to match your resume to the job description as best they can.  If the job ad says "10 years of experience with Oracle", then your resume may be rejected if it only lists 5 years, even if in those 5 years you have become an expert.  </p>

<p>My advice is to answer these questions the way you did initially, to get past the initial resume filter.  At the same time, look carefully at the job description yourself, and try to gauge if it is really a good match for your skills. </p>

Title: How do you quantify competency in terms of time (years)?

Body:
While looking for a job via agencies some time ago, I kept having questions from the recuitment agents or in the application forms like:

How many years of experience do you have in:

Oracle

ASP.NET

J2EE etc etc etc....

At first I answered faithfully... 5yrs, 7yrs, 2 yrs, none, few months etc etc..

Then I thought; I can be doing something shallow for 7 years and not being competent at it simply because I am just doing a minor support for a legacy system running SQL2000 which requires 10 days of my time for the past 7 years. Eventualy I declined to answers such questions.

I wonder why do they ask these questions anymore. Anyone who just graduated with a computer science can claim 3 to 4 years experience in anything they 'touched' in the cirriculum, which to me can be equivalent to zero or 10 years depending how you look at it.

It might hold true decades ago where programmers and IT skills are of very different nature. I might be wrong but I really doubt 'time' or 'years' are a good gauge of competency or experience anymore.

Any opinion/rebuttal are welcome!

Body:
I agree, this measure of competence is meaningless.  However, I am guessing that most recruiters do not know that.  They simply try to match your resume to the job description as best they can.  If the job ad says "10 years of experience with Oracle", then your resume may be rejected if it only lists 5 years, even if in those 5 years you have become an expert.

My advice is to answer these questions the way you did initially, to get past the initial resume filter.  At the same time, look carefully at the job description yourself, and try to gauge if it is really a good match for your skills.


答:
Your peer tells you after reviewing the code.

You cannot determine this yourself easily because as the author, you know more than the code says by itself.  A computer cannot tell you, for the same reasons that it cannot tell if a painting is art or not.  Hence, you need another human - capable of maintaining the software - to look at what you have written and give his or her opinion.  The formal name of said process is peer review.

ContentLicense: CC BY-SA 4.0


答:
Despite how it seems, there are some fairly objective measures you can consider.  Books like C++ Coding Standards, Refactoring, and Clean Code have long lists of criteria to judge your code by, looking at things like meaningful names, function sizes, principles like coupling and cohesion, object design, unit testing, successive refinement, etc.

The list is too large to be amenable to a checklist, but you read the book and pick out a few key things to work on, then after several months read it again to improve further.


答: I would say one way to know would be if new team members can pick up the code, understand it, and modify it to fix defects / meet new requirements with relative ease.</p>


答:
It is:

maintainable if you can maintain it.

easily maintainable if someone else can maintain it without asking you for help

readable if someone else, on reading it, correctly understands the design, layout and intent

The real test for 1. is (as Alex in Paris and quant_dev say) that you can pick it back up after a few months doing something else.

The test for 2. and 3. is that someone else can pick it up, and figure out how to extend or fix your code while following the grain of your design.  If they can't understand the design, how it relates to the problem space, or how your code is intended to be used, they'll hack a solution across the grain instead.

There are rules of thumb, principles (ie, rules of thumb someone wrote up nicely and gave a name) and all sorts of suggestions that may lead you in the right direction, or away from common pitfalls. None of them will guarantee the qualities you're asking for, though.


问:
Is it a waste of time to free resources before I exit a process?
Let's consider a fictional program that builds a linked list in the heap, and at the end of the program there is a loop that frees all the nodes, and then exits. For this case let's say the linked list is just 500K of memory, and no special space managing is required.

Is that a waste of time, because the OS will do that anyway?

Will there be a different behavior later?

Is that different according to the OS version?

I'm mainly interested in UNIX based systems, but any information will be appreciated. I had today my first lesson in OS course and I'm wondering about that now.

Edit: Since a lot of people here are concerned about side effects, and general 'good programming practice' and so. You are right! I agree 100% with your statements. But my question is only hypothetical, I want to know how the OS manages this. So please leave out things like 'finding other bugs when freeing all memory'.

答:
OK, I just got an Email back from my instructor, with a very good and reasonable answer. Here it is:

Hi Ramzi,

Thanks for the link to the interesting messages thread which you
  started.

As per our discussion, malloc operates on the process' virtual memory.
  So, when the process dies, its virtual address space "disappears", and
  any physical memory mapped to it is freed. Hence, disregarding "good
  software engineering practices" and such, dynamic memory de-allocation
  just before exiting a process is indeed a waste of time.

(Needless to say, this is not the case when a single thread terminates
  but other threads of that process keep executing.)

So according to this:

It is a waste of time

Will have no later affects

Is independent of OS versions.


问:
Pseudocode for Brodal queue
I'm trying to find more resources regarding Brodal heap. All I found is a haskell implementation of Brodal-Okasaki heap, but I think that they are skew heaps, is this correct? Furthermore, I'm illiterate in Haskell so that does not help much. Does anyone have (or know of) an Brodal queue implementation in pseudocode, C, C++, Python?

Also please correct if my assumptions above are wrong.

答: This is a partial answer since I've not yet figured out how to translate the code into something that's not Haskell. The reason as far as I can tell for them having  to use Haskell is that Haskell is lazy. The Brodal-Okasaki heap needs to be implimented in a lazy fashion from the paper. So what you'd need is a way of providing that functionality to another language along with any other requirements (such as purely functional data structures) that the BO Heap might need.</p>

Title: Pseudocode for Brodal queue


问:
Why was Tanenbaum wrong in the Tanenbaum-Torvalds debates?
I was recently assigned reading from the Tanenbaum-Torvalds debates in my OS class. In the debates, Tanenbaum makes some predictions:

Microkernels are the future

x86 will die out and RISC architectures will dominate the market

(5 years from then) everyone will be running a free GNU OS

I was a one year old when the debates happened, so I lack historical intuition. Why have these predictions not panned out? It seems to me, that from Tanenbaum's perspective, they're pretty reasonable predictions of the future. What happened so that they didn't come to pass?

答:
I think there are a couple of reasons that are pretty serious, but haven't been mentioned.

The first is Tanenbaum's rather blind assumption that technical superiority would lead to market dominance. People have argued for years about whether microkernels (nanokernels, picokernels, etc.) are technically superior, but for the moment, let's just assume they are. We're still left with a question of whether that technical superiority is likely to translate to market dominance. I will posit that it doesn't. For most people, Windows, Mac OS, etc., are  good enough. Worse,the improvements that would make a significant difference to most users would be in the user interface, not the kernel.

The second is drastically over-estimating the rate of change in a (reasonably) mature market. It's pretty easy to change things in a hurry when you have a new market. To get essentially everybody changed over in five years, the migration would had to have been happening at full speed even as he predicted it.

I'd also note another way in which he was right that I haven't seen mentioned. People have already noted the ubiquity of RISC (e.g., in cell phones). What they haven't mentioned is the ubiquity of what I'd call "microkernel 2.0". This is now more often known as a "virtual machine" or "hypervisor". They really are pretty much microkernels though.

The big difference is that Tanenbaum thought in terms of a microkernel and a user-mode OS emulation both designed specifically for each other. Instead, we've kept the OS essentially unchanged, and tailored the microkernel to run it as-is. This isn't as nice technically, but from a market perspective, it's dramatically superior -- instead of a whole new system top to bottom, the user can continue to use most of his existing code as-is, and just add a cool new "utility" that happens to really be a microkernel OS.


问:
What suitable Q & A application can integrate with a Java portal?
I'm looking for suggestions on whether we should build or are there readymade applications that do the following:

Allow admins to build a structured
workflow of support Q & A, similar to
Windows Troubleshooting i.e. when you
try one tip, you then get the next
one.

Allow end-users to search and follow
the Q & A

We have an existing Liferay portal which we would like to plug in this app to it - is there some suitable app like a CMS which does this? I mean building the structured questions - not just plain content like a wiki.

Open source options are welcome, but I'd like to know of COTS as well.

答: use Wordpress. Wordpress will have a core simple cms and you can extend it using its plugins.   It can be easily integrated with any kind of site.  To do those You need a good wordpress programmer.</p>


问:
Why can't I implement an interface which has a bounded generic type in this code in java?
I have the following interfaces:

```<code>public interface Successorable<E> extends Comparable<E>
    E suc();
}
</code>```

and

```<code>interface IInterval <E extends Successorable<E>> {
    E min();
    E max();
}
</code>```

I'm trying to implement IInterval by doing:

```<code>public class Interval<E> implements IInterval<E> {
 ....
</code>```

However eclipse complains that the type E is not a valid substitute for the bounded parameter <E extends Successorable<E>> of the type IInterval<E>.

What am I doing wrong?

Thanks!

答:
I believe you need to restate your conditions. The plain old E in Interval<E> doesn't necessarily fulfill E extends Successorable<E> so you need to be more specific about your parameter.

```<code>public class Interval<E extends Successorable<E>> implements IInterval<E> {
    @Override
    public E min() {
        throw new UnsupportedOperationException();
    }

    @Override
    public E max() {
        throw new UnsupportedOperationException();
    }
}
</code>```

Body:
I believe you need to restate your conditions. The plain old E in Interval<E> doesn't necessarily fulfill E extends Successorable<E> so you need to be more specific about your parameter.

public class Interval<E extends Successorable<E>> implements IInterval<E> {
    @Override
    public E min() {
        throw new UnsupportedOperationException();
    }

    @Override
    public E max() {
        throw new UnsupportedOperationException();
    }
}


问:
Should cookies be used in a RESTful API?
I'm specifically interested in how users perform authorized / authenticated operations on a web API.

Are authentication cookies compatible with the REST philosophy, and why?

答:
Yes and No - Depends how you use it.

Cookies if used to maintain client state at the client, for the client, of the client and by the client then they are restful.

If you are storing server state into the cookie then you are basically just shifting the load to the client - which isn't restful.

So what are some examples?

Restful:

Authentication details or 'is logged in' kinda stuff

last viewed page or place in application etc.

Not Restful:

Storing session information

Restfulness comes from statelessness - of the server. Clients can maintain application state and send it to the server to say where they are so that the server can decide where to go from there. Basically sessions/states need historical data and are dependent on past requests so to speak, restful applications ideally aren't (It's not viable to have a 100% pure restful application if you are going to have a login screen :)


问:
Sample code under MS-PL: must leave original comments?
I have some files in my project that started from a sample in the all-in-one code sample browser: http://visualstudiogallery.msdn.microsoft.com/4934b087-e6cc-44dd-b992-a71f00a2a6df

Some files contain boilerplate code that I modify heavily. They contain MS comments at the top that mention the license, copyright microsoft etc.

Am I required to leave the entire comment block at the top of the source files that I modify or is it okay to just include the MS-PL license in a separate file for the whole project?

答:
I believe that you do need to keep those notices, per section 3.C of the licence:

If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.


问:
Best Practices To Build a Product Registration System?
What are some practices I should use in a product registration system I'm building? I likely can't stop all malicious hacking, but I'd like to slow them down a great deal. (Note, I know only PHP.) I'm talking about things like encrypting traffic, testing the encryption from hacking like a man-in-the-middle attack, etc. The other concern I have is that this needs to work on most PHP5-based web hosting environments, which may not have mcrypt installed.</p>

答:
To encrypt traffic and prevent MITM attacks you need to require SSL to access your app and get a certificate from a certification company (i.e. Verisign). This isn't done through code though, its configured on the hosting server.

Other security measures you need to take are to parametrize everything you put in a SQL statement to prevent SQL injection. you will also need to ensure that you ensure a user is authorized to view every page so incrementing some id in the url doesn't result in showing unauthorized information. You also need to use a salted hash to stored user passwords, and properly hash or encrypt other sensitive information in the database appropriately. Do not store old passwords. Make sure that security patches are applied in a timely manner, ensure your code is not susceptible to newly discovered vulnerabilities when they are revealed. Limit access as much as possible, separate duties as much as possible.

That's all the basic security stuff off the top of my head


问:
What are the benefits of closing every if-statement with an else in Python?
I am reading Learn Python the Hard Way by Zed Shaw.  In this lesson he writes: "Every if-statement must have an else."

What are the benefits of ending every if-statement with an else?  Are there any legitimate reasons not to end an if-statement with an else?

答:
I have worked with code that has a case that "absolutely won't happen".  And then it happens...  Even if the else clause logs the problem it makes sure that you'll find it when it bites you later on.

I don't know much about code coverage, but I would think you would get better results if all paths are covered.


答:
I think it depends on what your purpose is. If you want for example to error check a function you dont need an else-statement:

```<code>    def foo(bar):
        if(bar<0 or bar>10) or not isinstance(bar,int):
            return -1
        print "successfull"
        print bar
</code>```

But if you something more complex like if that... do this this this... and else... do this this this... then you should do "else" for readability, even if it is not really necessary.

Title: What are the benefits of closing every if-statement with an else in Python?

Body:
I am reading Learn Python the Hard Way by Zed Shaw.  In this lesson he writes: "Every if-statement must have an else."

What are the benefits of ending every if-statement with an else?  Are there any legitimate reasons not to end an if-statement with an else?

Body:
I think it depends on what your purpose is. If you want for example to error check a function you dont need an else-statement:

    def foo(bar):
        if(bar<0 or bar>10) or not isinstance(bar,int):
            return -1
        print "successfull"
        print bar

But if you something more complex like if that... do this this this... and else... do this this this... then you should do "else" for readability, even if it is not really necessary.


问:
How to market yourself as a software developer?
I have noticed that this is a frequent issue among younglings from technical areas such as ours.

In the beginning of our careers we simply don't know how to sell ourselves to our employers, and random guy #57 (who is a programmer, but not as good as you - technically) ends up getting a raise or a promotion because he knows how to communicate and market himself better than you. Many have probably seen this happen in the past, and most certainly many more will in the future.

What kind of skill/ability (either technical, or of other nature) do you think is relevant to point out when doing a job interview or asking for a raise, besides listing all the programming languages and libraries you know?

答:
When distinguishing yourself for a job outside your current position:

Network locally to meet people at other companies

Network at national events if you get the chance

Do presentations

Write a blog

Contribute to an Open Source project

Publish a book

Answer questions on a site like this one

Show accomplishments on your resume in business terms (what problems
did you solve, how much money did you save the company, etc.)

Internally the dynamics are a bit different.

First you have to get a reputation as a person who knows his stuff, who can produce good quality work under deadline stress and who can solve problems. You also often need a reputation as a team player (which means something different to managers than low level employees, more on that below).

But not only do you have to do these things, you have to make sure the people above you know you did them.  So make sure to mention the things you do in team meetings, forward any emails that praise your work to your boss. If someone praises you in a conversation, ask them to tell your boss. If you have a bulletin board at work where employees praise is posted, make sure that you get on it.  Make sure to introduce yourself to senior managers whenever you get the chance. Promotions are often decided at a higher level than your boss - make sure those people have heard your name in positive way. If you have a something like Yammer at work where employees can discuss business or personal related things and the whole company can join in, stick to business issues and make sure to write some interesting things that may get the attention of senior managers. They use these tools to look for talent to promote.

Be someone they can trust to deliver. Don't disappear in your cubicle dark hole and only come out when something is done. Give progress reports; bring it up as soon as possible when there is a possible delaying factor or show stopper. Admit mistakes and when you do go in with a plan to fix the problem. Find some work-related problems and go to your boss with a suggestion as to how to fix it. Be the go-to guy when everyone else is stuck.

Be a team player. This isn't just helping others on your team and mentoring although that certainly doesn't hurt. But managers expect you to support them and to support company policies in public. NEVER let your boss get blindsided by a problem you knew about. If you disagree with something (and it's not a brainstorming meeting where you are expected to discuss the pros and cons), then talk to your boss in private. And the time to disagree on a technical issue is before the decision has been made. Bringing up an issue that has been decided repeatedly (especially in public) or worse, ignoring the decision to do what you wanted to do anyway will put you on the fast track to the bottom of the promotion list.

If you have a chance to interface directly with users grab it. Those users that geeks write off as stupid often have the ear of the senior managers and impressing them can be good for your career. If you have the chance to do a special project that may involve something other than coding, grab that too. Successful special projects are a good way for senior managers to get to know your name.


答:
Directly under the list of rules is the following statement:

Never be a slave to the rules in real life. For training purposes you need to follow these rules to make your mind strong, but in real life sometimes these rules are just stupid. If you think a rule is stupid, try not using it.

It looks like the rules are setup to be overly cautious because the target audience is just starting. By doing this, it forces the student to form good habits when writing future code. If you are able to explain why you no longer think the rule is worth following (and support it with a good reason), you are already thinking deeply on the issue. This means you have weighed the options and decided to accept what risk there might be. You are also less likely to make a mistake the rule would have prevented if you have spent that much time thinking about the rule.


问:
How many indexes is too many indexes?
I have a table with about 37 indexes. Would that be considered too many? What are some best practices regarding indexing?

EDIT: It is warehousing data, updated daily with new transactions.  There are 47 million rows.  3 of the indexes are very necessary. The other 34~ are 'where' clause indexes intended to speed up queries.

答:
One more index than you need is too many. One less is too little.

I've tried searching for a case where having too many indexes was a
  problem and couldn't really find anything

You KNOW you have too many if your inserts are too slow, and the index used for reading   are not speeding things up enough to make up for it.

Title: How many indexes is too many indexes?