问:
Is it better to use a Database or a data structure for network stack?
I've built a multi threaded messaging application in C and I'm currently using a MySQL Memory table to save the session ID, but I'm not sure whether this was a good decision or not.

It works like this, the application sends a message and saves the source session ID in the MySQL table. When the application gets the success response it will remove the session's ID from the MySQL table, or if it received an error response then it will keep the ID to be retried later.

I've built it this way so that I don't need to care about building a data structure by myself, and the Database provides flexibility when it comes to querying it.

Do you think this is appropriate or do I need to use something else? Please note that the application is expecting to handle a large number of transactions/sec.

答:
You can instead use NDB engine to improve performance and concurrency.
High performance replacement of the MySQL Memory storage engine with NDB</p>


答:
If you can fit everything into available memory why not use one of the many Hash map libraries/templates available for C/C++.

You will get a massive performance boost (no disks, no IO, no parsing no .....) and most of the APIs available are pretty simple to use.

Have a look at this comparison to see which one would best suit your needs.

ContentLicense: CC BY-SA 3.0

Title: Is it better to use a Database or a data structure for network stack?

Body:
I've built a multi threaded messaging application in C and I'm currently using a MySQL Memory table to save the session ID, but I'm not sure whether this was a good decision or not.

It works like this, the application sends a message and saves the source session ID in the MySQL table. When the application gets the success response it will remove the session's ID from the MySQL table, or if it received an error response then it will keep the ID to be retried later.

I've built it this way so that I don't need to care about building a data structure by myself, and the Database provides flexibility when it comes to querying it.

Do you think this is appropriate or do I need to use something else? Please note that the application is expecting to handle a large number of transactions/sec.


问:
Is the 'C' in MVC really necessary?
I understand the role of the model and view in the Model-View-Controller pattern, but I have a hard time understanding why a controller is necessary.

Let's assume we're creating a chess program using an MVC approach; the game state should be the model, and the GUI should be the view. What exactly is the controller in this case?

Is it just a separate class that has all the functions that will be called when you, say, click on a tile? Why not just perform all the logic on the model in the view itself?

答:
A Controller could help abstract the interfaces of both the View and the Model so that they don't have to know about each other directly.  The less an object has to know, the more portable and unit testable it becomes.

For instance the Model could be playing another instance of itself thru one Controller.  Or a networked Controller could connect two player's Views objects together.  Or it might be a Turing test where nobody knows which.

Title: Is the 'C' in MVC really necessary?


答:
Why not just perform all the logic on the model in the view itself?

The controller is the glue that binds the model and view together, and it's also the insulation that keeps them apart. The model shouldn't know anything about the view and vice versa (at least in Apple's version of MVC). The controller acts like a two-way adapter, translating user actions from the view into messages to the model and configuring the view with data from the model.

Using the controller to separate the model and view makes your code more reusable, more testable, and more flexible. Consider your chess example. The model would of course include the game state, but it might also contain the logic that affects changes to the game state, such as determining whether a move is legal and deciding when the game is over. The view displays a chess board and pieces and sends messages when a piece moves, but it doesn't know anything about the meaning behind the pieces, how each piece moves, etc. The controller knows about both the model and the view as well as the overall flow of the program. When the user hits the 'new game' button, it's a controller that tells the model to create a game and uses the new game's state to set up the board. If the user makes a move, the controller relays the command to the model and, based on the response, allows the move or not.

Look at what you get by keeping model and view separate:

You can change the model or the view without changing the other. You may have to update the controller when you change either one, but in a way this is part of the advantage: the parts of the program that are most likely to change are concentrated in the controller.

Model and view can both be reused. For example, you could use the same chess board view with an RSS feed as a model to illustrate famous games. Or, you could use the same model and replace the view with a web-based interface.

It's easy to write tests for both model and view to ensure that they work the way they should.

Both model and view can often take advantage of standard parts: arrays, maps, sets, strings, and other data containers for the model; buttons, controls, text fields, image views, tables, and others for the view.

Title: Is the 'C' in MVC really necessary?

Body:
I understand the role of the model and view in the Model-View-Controller pattern, but I have a hard time understanding why a controller is necessary.

Let's assume we're creating a chess program using an MVC approach; the game state should be the model, and the GUI should be the view. What exactly is the controller in this case?

Is it just a separate class that has all the functions that will be called when you, say, click on a tile? Why not just perform all the logic on the model in the view itself?


问:
Are there any actual case studies on rewrites of software success/failure rates?
I've seen multiple posts about rewrites of applications being bad, people's experiences about it here on Programmers, and an article I've ready by Joel Spolsky on the subject, but no hard evidence or case studies.  Other than the two examples Joel gave and some other posts here, what do you do with a bad codebase and how do you decide what to do with it based on real studies?

For the case in point, there are two clients I know of that both have old legacy code.  They keep limping along with it because as one of them found out, a rewrite was a disaster, it was expensive and didn't really work to improve the code much.  That customer has some very complicated business logic as the rewriters quickly found out.

In both cases, these are mission critical applications that brings in a lot of revenue for the company.  The one that attempted the rewrite felt that they would hit a brick wall if the legacy software didn't get upgraded at some point in the future.  To me, that kind of risk warrants research and analysis to ensure a successful path.

Have there been actual case studies that have investigated this?  I wouldn't want to attempt a major rewrite without knowing some best practices, pitfalls, and successes based on actual studies.

Aftermath:  okay, after more searching, I did find three interesting articles on case studies:

Rewrite or Reuse.  They did a study on a Cobol app that was converted to Java.

The other was on Software Reuse: Developers Experiences and Perceptions.

Reuse or Rewrite Another study on costs of maintenance versus a rewrite.

I recently found another article on the subject: The Great Rewrite. There the author seems to hit on some of the major issues.  Along with this was the idea of prototyping by using the proposed new technology stack and measuring how quick the devs picked it up.  This was all as a prelude to a rewrite, which I thought was a great idea!

答:
You aren't going to find many non-biased case studies that are anything other than after action reports -- most people are not going to pay to have the same work done least twice (once as a rewrite, once as an upgrade, best case would be multiple rewrites/upgrades by different teams).

The case study that you found seems to have been produced by Fujitsu, and unsurprisingly the result was that it was better to use Fujitsu's tools.

From an organizational point of view, a rewrite is only clearly a failure when either the rewritten application doesn't work, or the project is canceled before it is finished -- otherwise it's impossible to know whether the delay in releasing the rewritten version was the cause of whatever loss you suffered or merely coincidental.  If canceled before finished, it's generally considered a total waste of time and resources.  An upgrade can potentially have the same problem, but being incremental is unlikely to be on the same scale (you get something for your money).

Best case from a programming perspective is to do both -- incremental upgrades while rewriting, both supporting and inspiring each other.  Unless you have different teams this will naturally take longer.

Note that this provides a rough guideline for when you should consider a total rewrite -- the project is small enough that you can do so easily, or the orgainization is large enough that it can afford to do both, counting the effort or the learning cost worthwhile.  Also note that if the rewrite never catches up to the rework, that can mean several things, but all else being equal, it probably means that a rewrite was unnecessary.


问:
Is OO-programming really as important as hiring companies place it?
I am just finishing my masters degree (in computing) and applying for jobs. I've noticed many companies specifically ask for an understanding of object orientation.  Popular interview questions are about inheritance, polymorphism, accessors etc.

Is OO really that crucial?  I even had an interview for a programming job in C and half the interview was OO.

In the real world, developing real applications, is object orientation nearly always used?  Are key features like polymorphism used A LOT?

I think my question comes from one of my weaknesses. Although I know about OO, I don't seem to be able to incorporate it a great deal into my programs.

答:
It depends. One reason you need to know OO because it's the lingua franca of the programming world. As another answer points out, nearly every major language is OO in some way, which means that basically any company that might hire you is using an OO language.  Ever try hiring OCaml programmers? It's impossible; the talent pool is too small. If you started your company using OCaml and your company becomes successful, you won't be able to hire programmers fast enough and you'll go out of business. Therefore nearly every company with more than 3 programmers uses an OO language, and in order to communicate with your coworkers and use your platform's libraries, you'll need to have an understanding of OO.

Depending on the particular language the company is using, inheritance and polymorphism is either extremely important or just moderately relevant. You can't do anything in Java without busting out 10 GoF design patterns and a dependency injection framework. Java is one of the most widely-used languages, therefore OO principles are really important to the many companies using Java.

If the company is using a modern hybrid OO/functional language that has lambdas and function pointers, like Scala or C#, then inheritance suddenly becomes less important because you have higher order functions to handle lots of the really simple things that would otherwise require lots of ceremony. However you still need to be able to work with OO stuff because most libraries you use will be written in an OO way.

If inheritance and polymorphism aren't important to the company, you're still likely to get OO questions because:

You are interviewed by an HR person who knows nothing about programming and is asking questions off a checklist. Do you have 3 years of X, do you multitask, etc.

You are interviewed by an engineer who wants to make sure you haven't been living under a rock. OO is the lingua franca, so you'll be asked some cursory questions about it.

You are interviewed by an engineer who isn't very adept at interviewing. In general, engineers love trivia and complexity, so you will get a lot of questions about polymorphism, inheritance, and GoF design patterns only because these things are interesting to the person interviewing you.


答:
There are many, many different ways of implementing this general design pattern, but the basic idea is to separate the various concerns as necessary. MVC is a nice abstraction in the sense that:

Model: Represents that data, whatever that might mean

View: Represents the user interface, whatever that might mean

Controller: Represents the glue that causes that model and view to interact, whatever that might mean

It's extremely flexible because it doesn't specify a whole lot. A lot of people waste a lot of bandwidth arguing the details of what each element might mean, what names should be used instead of these, and whether there should really be 3 or 2 or 4 or 5 components, but that's missing the point to a certain degree.

The idea is to separate out the different "chunks" of logic so that they don't overlap. Keep your presentation stuff together, keep your data stuff together, keep your logic stuff together, keep your communication stuff together. And so forth. To a certain extent, the less these areas of concern overlap, the easier it is to do interesting things with them.

That's all you really should be worrying about.

Title: Is the 'C' in MVC really necessary?


问:
Does giving a developer a slower development machine result in faster/more efficient code?
Suppose I give my developers a screaming fast machine.  WPF-based VS2010 loads very quickly.  The developer then creates a WPF or WPF/e application that runs fine on his box, but much slower in the real world.

This question has two parts...

1) If I give a developer a slower machine, does that mean that the resulting code may be faster or more efficient?

2) What can I do to give my developers a fast IDE experience, while giving 'typical' runtime experiences?

Update:

For the record, I'm preparing my even-handed response to management. This isn't my idea, and you folks are helping me correct the misguided requests of my client.  Thanks for giving me more ammunition, and references to where and when to approach this.  I've +1'ed valid use cases such as:

- specific server side programming optimizations

- test labs

- the possibly buying a better server instead of top of the line graphics cards

答:
I'm tempted to say "No" categorically, but let me share a recent experience: Someone on our project was working on some code to import data into the database.  At the time he had the oldest PC in our group, maybe even the entire organization.  It worked fine with VS 2008, but of course a faster machine would have made the experience better.  Anyway, at one point the process he was writing bombed while testing (and that's before it was fully-featured).  He ran out of memory.  The process also took several hours to execute before it bombed.  Keep in mind, as far as we knew, this is what the users would have had to use.

He asked for more RAM.  They refused, since he was getting a newer machine in 3-4 weeks and the old one was going to be discarded.

Keep in mind that this guy's philosophy on optimization is: "We have fast machines with lots of RAM" (his and a few machines excluded, anyway), so why waste valuable programmer time optimizing?  But the situation forced him to change the algorithm to be more memory-efficient so that it would run on his 2Gb machine (running XP.)  A side-effect of the rewrite is that the process also ran much, much faster than it did before. Also the original version would eventually have bombed even with 4Gb when more data was being imported - it was a memory hog, plain and simple.

Soooo... While generally I'd say "No", this is a case where the developer having a less powerful machine resulted in a better optimized module, and the users will benefit as a result (since it's not a process that needs to be run very often, he initially had no intention of optimizing it either way, so they would have been stuck with the original version if the machine had had enough RAM to run a few large tests...)  I can see his point, but personally I don't like the idea of users having to wait 8 hours for a process to complete, when it can run in a fraction of that time.

With that said, as a general rule programmers should have powerful machines because most development is quite intensive.  However, great care should be taken to ensure that testing is done on "lowest common denominator" machines to make sure that the process doesn't bomb and that the users won't be watching paint dry all day long.  But this has been said already. :)

ContentLicense: CC BY-SA 2.5


问:
How can a single developer make use of Agile Methods?
I am a freelancer and work as a single developer. In all cases, I am the person wearing different hats. I am the Scrum Master and I am the only person in the development. What I am not is the Product Owner?

Are there any Agile Methods and free tools that a freelancer can make use of?

答:
The goal of Agile is to...

minimize all feedback loops as much as possible

minimize project overhead in terms of documents/forms produced and replace it with much higher bandwidth medium, which is real-time (preferably face-to-face) communications among team members.

If you do more research about agile, a lot of it will talk about teams and the interaction between members. That's because with every Nth member, number of lines of communications within the goes up by N.  As N goes up, you face additional challenges such as training/knowledge dissemination, coordination of effort...

A lot of the problems that an agile team would face, you would definitely not need to worry about, but the main area where I would focus is (1) - minimizing feedback loops. Even as a single developer this comes in very handy because the sooner you identify problems (whether it is requirements, design or implementation) the less expensive it will be to fix those problems.

This is what I would do:

Make it a point to meet with your customers on regular basis and make sure they...

know exactly what you've done and provide you feedback as soon as possible

know what you are working on next and confirm those are the features they actually want given what they already see as being completed

Spend some time on ironing out deployment/packaging.  A little of upfront cost will ensure that with one button click you can roll out a fully deployable version of your application which can be instantly tested.  I'm not sure how much continuous integration server would benefit a one-person team - curious what other's would say about that.

You can manage your product backlog much the same way agile teams do it. However, since you are working by yourself, I would skip using any type of fancy software and even whiteboard with posted notes and go right to a text file (maybe excel sheet) that lists work items. Prioritize them and regularly review them to make sure that you are not missing anything and that the important things are taken care of first.  If you want to try something a little fancier, Trello, might be a good option

Consider moving over to TDD. A year ago I was a bit skeptical and considered TDD only useful for low-level utilities that have no dependencies on anything else.  But in the last year, I've tried the approach several times and each time was extremely surprised at the results.  Yes, it is a hefty chunk of upfront cost, but it seems that the benefits from having your code easily testable/verifiable ends up paying you back crazy fast.

TDD will instantly tell you if you made a mistake in the code and you can easily verify that your classes/functions behave properly in boundary conditions. Alternative is typically to "do your best", but you end up finding bugs during testing and then you end up spending hours isolating and debugging the problem.

With unit tests in place, you won't be nearly as scared about refactoring and significantly altering the design as new features are added.  I noticed without TDD, most people tend to be scared of touching code that's already been tested (and rightfully so).  In a lot of cases, they keep adding on more and more, while afraid to alter what's already there and the code ends up looking like a legacy spaghetti mess even before v1.0 is shipped.

With tests in place and being able to refactor at will, also gives you the advantage that you don't need to stress as much about getting the design right the first time since it becomes that much easier to alter the design as needed later on.

Carry out your own retrospectives. One of the key messages of agile is that change should be welcomed and that we should never settle into a rhythm where the same thing is being done over an over. Periodically evaluate what you are doing and try to identify areas were you feel different approach could make your more efficient. Don't be afraid to adjust the process (or sometimes drastically change something, if for now other reason, then just to see what would happen) and tailor your practices to your specific situation.

The advice I provided is based on the type of work I've done, which mainly involves working on an application sold as a product. We work on the same code base and keep extending/improving the same application with each new release.  Advice might be different if your primary source of income is coding as a service (i.e. write some code, sell it, never see it again).  The impression I'm getting is that developers in the services area, tend to skip TDD and many other practices since extendable/maintainable code is not their priority.  Instead, they focus on time to completion (i.e. minimizing costs) and making sure that v1.0 (which is the first and last version) passes customer's acceptance criteria.


问:
Low level Linux graphics
For educational purposes, I'd like to write an application on a Linux environment that can process keyboard events and draw graphics without huge dependencies like X or SDL. I presume that this must be possible, because X and SDL are just programs themselves, so they must rely on other methods inherent to the environment. Is this understanding correct?

If so, where might I learn to write such a program? My limited experience tells me that it would involve making calls to the kernel, and/or writing to special files; however, I haven't been able to find any tutorials on the matter (I am not even sure what to Google).

Also, in case it is relevant, I am running Debian Squeeze on Virtualbox. I have used a netinst cd without networking, so there isn't much installed on it currently. I will install gcc, but I am hoping I can get by with nothing more.

答:
X (or the X Window System) is practically the most low-level graphics API a Linux application will likely use on a modern Linux Desktop. Most applications won't even bother going that deep and will instead use a GUI toolkit implementation like GTK or Qt.

Below that there's only the hardware drivers and probably some X-internal APIs for the drivers. But those are not meant or designed to be used by normal userspace applications.

You could use the kernel framebuffer device (fbdev), but I don't know how well that supports modern graphics API.

Edit: Wayland is an alternative to X that has only recently found some mainstream adoption. It is now possible to run a Linux-Desktop purely on Wayland with no X-Windows system running at all. Wayland itself depends on an EGL driver underneath (an API strongly related to OpenGL).

Title: Low level Linux graphics

ContentLicense: CC BY-SA 4.0


答:
All good answers so far.  My two cents is that I like to think of the controller as primarily being built up with questions like What and where?

I've been asked if a chess piece (view) can be moved to x.  Is it

allowed?  I'm not sure but I know where and who to ask (the model).

Something has asked me to save my data.  How the heck do I do that?
I know where to ask though! How we save the data, or where it's saved to,
I've got no idea, but that Repository class should know.  I'll forward it and let it deal with it.

I've got to show the current chess piece position to the user that
the model moved it to.  not sure if I want to show the piece as green
or yellow?  Bah, who cares, I know there's a view that can handle
this so I'll pass em the data and they can decide how it's going to
be showen.

These little snippets are examples of how I'm trying to remember the abstraction and concept MVC is trying to convey.  What, Where, and How are my three main thought processes.

What and where => Controller
How and when => Models and views

In essence my controller actions tend to be small and compact and when reading them tend to look sometimes like a waste of time.  In closer inspection they are acting as the traffic signal man, channeling the various requests to the appropiate workers but not doing any of the actual work themselves.

Title: Is the 'C' in MVC really necessary?


问:
Mulitple processes aware of each other
Hope you can help me with this, I've searched a lot and I got really confused of what to do here.

I'm building a program in C and I need to run it multiple time as I need.

So it's going to be like below,

process 1 handle all rows on DB table test where process_flag=1

process 2 handle all rows on DB table test where process_flag=2

process 3 handle all rows on DB table test where process_flag=3

and so on

How can I make the processes aware of each other, so if process 3 goes down then processes 2 & 3 start working on process_flag=3?

答:
The general design of such architecture is inter-process communication.

They are based mostly on:

shared memory,

message queues,

semaphores,

files,

underlying specific OS mechanisms such as Unix signals or Apple events.

Title: Mulitple processes aware of each other


答:
Maybe Personal eXtreme Programming might be something you might want to take a look at?

https://www.google.nl/search?q=personal+extreme+programming

It's a method that is a combination between extreme programming practices and the practices of the Personal Software Process(PSP) devised by Watts S. Humphrey of Carnegie Mellon University.
PSP is quite rigid in its approach and not agile. PXP is a more agile adaptation of personal software development. PXP isn't really something you'd call mainstream, but I've used it in the past, and it has worked for me. I've adapted a PXP approach based on some papers I've read on the topic:

https://research.uni-sofia.bg/bitstream/10506/647/1/S3T2009_37_YDzhurov_IKrasteva_SIlieva.pdf

http://dl.acm.org/citation.cfm?id=1593127

PXP involves the following PSP practices:

•Time Recording:
Basically your time sheet. This is useful to determine your rate of progress.

• Size Measurement:
You have to have some kind of metric to measure the amount of work you've done. Usually this boils down to Lines of Code (LoC)

• Defect Type Standard:
A list with which you catagorize the types of bugs you encounter.

•   Process Improvement Proposal:
You have to have some kind of plan to improve your own process. Basically you'll need to plan some activities for self evaluation and review. You'll have to make a plan before implementing it. (And review the plan once in a while to tweak it)

•   Defect Recording:
You have to keep track of the bugs you found so you can analyse your behaviour afterwards.

•   Code Reviews:
This is a bit tricky, but somehow you have to review your code. I din't find this particularly interesting until I managed to mentally detach myself from my own work. Still you usually don't spot your own faults as easily as others do.

There area also some XP related activities:

•   Continuous Integration:
PXP includes the practices of source control versioning, automated builds, automated test executions, and automated  defect submitting. I find this practice very usefull. (I prefer the gated check-in approach, but that requires some scripting to set up, you might find that to be too much trouble)

•   Simple Design:
KISS! You probably know what I'm talking about. (if not, google it)

•   Small releases:
Make the milestones in your sprints small enough to keep things in perspective and not run the risk of spending a huge amount of time on features you've committed to, but can't deliver on in time.

•   Refactoring:
Standard agile practice, really.

•   Test Driven Development:
This too shouldn't be too unfamiliar.

•   Spike Solutions:
if you have a problem that you're new to, or that is hard to solve, take a step back and try to solve it in a stand alone setting before you try to integrate it in your big project.

TL;DR: it boils down to the tracking rigor present in the PSP/TSP (CMMi) style combined with common practices of XP minus the team efforts that are required for XP style processes.

Title: How can a single developer make use of Agile Methods?

Body:
I am a freelancer and work as a single developer. In all cases, I am the person wearing different hats. I am the Scrum Master and I am the only person in the development. What I am not is the Product Owner?

Are there any Agile Methods and free tools that a freelancer can make use of?


问:
How is a Java reference different from a C pointer?
C has pointers and Java has what is called references. They have some things in common in the sense that they all point to something. I know that pointers in C store the addresses they point to. Do reference also store the address? How they are different except that pointer is more flexible and error-prone?</p>

答:
References might be implemented by storing the address. Usually Java references will be implemented as pointers, but that's not required by the specification. They may be using an additional layer of indirection to enable easier garbage collection. But in the end it will (almost always) boil down to (C-style) pointers being involved in the implementation of (Java-style) references.

You can't do pointer arithmetic with references. The most important difference between a pointer in C and a reference in Java is that you can't actually get to (and manipulate) the underlying value of a reference in Java. In other words: you can't do pointer arithmetic.

In C you can add something to a pointer (i.e. the address) or substract something to point to things that are "nearby" or point to places that are at any place.

In Java, a reference points to one thing and that thing only. You can make a variable hold a different reference, but you can't just ask it to point to "the thing after the original thing".

References are strongly typed. Another difference is that the type of a reference is much more strictly controlled in Java than the type of a pointer is in C. In C you can have an int* and cast it to a char* and just re-interpret the memory at that location. That re-interpretation doesn't work in Java: you can only interpret the object at the other end of the reference as something that it already is (i.e. you can cast a Object reference to String reference only if the object pointed to is actually a String).

Those differences make C pointers more powerful, but also more dangerous. Both of those possibilities (pointer arithmetic and re-interpreting the values being pointed to) add flexibility to C and are the source of some of the power of the language. But they are also big sources of problems, because if used incorrectly they can easily break assumptions that your code is built around. And it's pretty easy to use them incorrectly.


问:
What does an MSDN subscription offer?
I'm curious because I notice that the Ultimate subscription costs $12,000... for one year (after that, it's $3,800 to renew). Looking at the subscription chart, you do get quite a bit of software that is normally expensive by itself.

Is the package meant for 1 person or is it meant for like a business-type bundle of some sort? If it's the latter, I can kind of understand that, but I can't fathom where anybody is going to have 12 grand to plop down on something that only lasts 12 months.

Anyway, yeah, my question is, is this a good deal to anyone at all? Maybe it's just me not having any industry experience and this is actually a steal and millions of companies should be buying it right now, but I just can't personally picture this being worth the money.

答:
You can still use the software you get through the subscription even after it expires. You just have to make sure you have all of it downloaded and the license keys on hand. So that $12000 buys you a lot of software. If you're a contractor, you might find it very useful/justifiable. If you're a major software company and you want your developers to use Visual Studio Ultimate and whatever else a subscription offers (there are also training packages included, for example), then you buy it for your developers.

Far as I know, MSDN subscriptions are for individuals. Companies can get in on the volume licensing instead.

Title: What does an MSDN subscription offer?


答:
C++ references are different again.

They have to be initialized and can't be null (at least not in a well formed program) and can't be reseated to refer to something else. a C++ reference is much more like an alias for an object.

Another important difference between pointers and Java/C++ references is that you can take the address of a pointer you cannot access the address of a reference (indeed a C++ reference need not actually exist as an object in memory at all) consequently you can have a pointer to a pointer but not a reference to a reference

Title: How is a Java reference different from a C pointer?

Body: C has pointers and Java has what is called references. They have some things in common in the sense that they all point to something. I know that pointers in C store the addresses they point to. Do reference also store the address? How they are different except that pointer is more flexible and error-prone?</p>


问:
What is the actual purpose of MVC?
I've seen a lot of stuff that describes how it's done, but not a lot that tells WHY it's done. Is it just a way to keep the code readable, or is there a better reason?</p>

答:
It's about Separation of Concerns.  Basically, you want your software components to do one thing, and one thing only.  If your components start doing more than one thing, code gets hard to read, things become more complicated than they need to be -- basically an app turns into a big plate of Spagetti Code.

The Models contain the business logic, represent the things in your application.  The views present the data to the user.  The controllers decide what to do with the various user actions.  When you stick to that, the code is easy to read because things are as simple as possible.

MVC is a popular pattern, but it's not the only one out there. MVVM is also popular.  As long as you separate your concerns, pick any design architecture that suits you.

OwnerDisplayName: Michael Dorst

Title: What is the actual purpose of MVC?

OwnerDisplayName: hvgotcodes


答:
The actual purpose of MVC is to separate your views from your controller and model. In other words, it is a design pattern is a structure for keeping display and data separate to allow each to change without affecting the other. By saying so, it is mostly used for GUI stuffs. Thus it essentially contains three things. The Model contains what is often called
business logic, or all the data and information manipulated by your system. The
View contains the objects that display the data, and the Controller manages the
interaction with the user and mediates between the Model and the View.

In many modern GUI toolkits, view and controllers are somewhat inter-related and thus cannot be fully separated. For example, a button is a controller but it needs to be displayed in the screen.

Title: What is the actual purpose of MVC?

Body: I've seen a lot of stuff that describes how it's done, but not a lot that tells WHY it's done. Is it just a way to keep the code readable, or is there a better reason?</p>


答:
Thats a big question I don't have time for that big of an answer, so I'll try to keep it short.

The primary reason is like you said for keeping the code readable and manageable.  The separation of these main components model, view and controller help to create more reusable code that is easier to understand because each piece has a distinct purpose.  The model representing the objects or data within the system and containing the code for the actions that can be performed on those objects.  The view of course encapsulating the layout and design that allows you to view that data.  And finally the controller that allows you to navigate from view to view, action to action.

If you have ever dealt with a large system of code that married the three of these together, you will have seen the typical copying of large chunks of redundant code that was not quite what was needed for the next task.  These models are built in such a way that they are more generic making them more reusable than it was inline.  That is you dont have SQL statements scattered throughout your scripts instead it is consolidated.  The same is true of HTML being scattered in code, very undesirable and hard to edit and maintain.

Hope that helps.

Title: What is the actual purpose of MVC?

OwnerDisplayName: AaronM


问:
How does using a LGPL gem affect my MIT licensed application?
I am developing an open source ruby application under the MIT license.  I am using this license because I don't want to place any restrictions on the users of the application.  Also I can actually read and understand this license.

I recently started using another ruby gem in my project (require "somegem").  This ruby gem is under the LGPL license.

Do I have to change anything about my project because I am using this other ruby gem that is licensed with LGPL?  My project does not contain the source code for the other gem and it is not shipped with my project.  It is simply listed as a dependency so that ruby gems will install it and my project will call into it from my code.

Additionally, it would be helpful to know if there are any licenses I need to "watch out for" because using them would affect the license of my project.

There are some other post about this topic but phrased in different ways.  Since I find this license stuff tricky I am hoping to get a answer directed at my situation.

Thank you,

Corsen

答:
It does not affect

LGPL — stands for Lesser GPL (used to mean Library GPL). The significant difference with GPL is, that it doesn't impose the license on software using the library. Only if you'd modify the library or directly include parts of the code in your software, then your code would have to be LGPL. On the other hand if you're just using gem in your app, it's perfectly fine to keep your app with any license you please.

The mentioned part of LGPL:

A program that contains no derivative of any portion of the Library,
  but is designed to work with the Library by being compiled or linked
  with it, is called a "work that uses the Library". Such a work, in
  isolation, is not a derivative work of the Library, and therefore
  falls outside the scope of this License.

OwnerDisplayName: corsen


问:
How Does Download Size Affect Potential Users of Your Product
Does anyone know (or, I guess, I have gut feeling about) how the download size of a software product affects potential users, bandwidth not withstanding?

For example: Does a bigger download make them
   believe that is it more full-featured
   than it is (like huge .NET Runtimes
   if deployed with your package)?

Reason is, I'm developing a VSTO add-in where there is my add-in (small MB), the VSTO run-time, .NET runtime, and Primary Interops. This could make it more than 70 MB in total size, just for an add-in that does a couple of things well. But that's all they are - just a couple of things.

With VSTO deployments, I know I could deploy a smaller package size by assuming they've got the .NET runtime (and when they don't, initialize the download/install of that, but it seems like a clunky way to make just an ass out of me).

What I really want is for people to just download the app (the trial version) to see if they like it. Is there some kind of magic happy threshold - like users of non-big name apps are more likely to download something that is under 20 MB than 50 MB?

答:
Who are you targeting? Most people couldn't care less about download sizes. If you're targeting tech users, then I'd say most of them would prefer a smaller download, which signals that your software isn't bloated. But even then, it's really not a huge deal.

I wouldn't include runtimes in a download if they are several times larger than the application/plugin itself, which sounds to be the case. I'd have the installer search for prerequisites, and if one isn't found, either (1) prompt the user to download and install (ask, and then launch a web browser), or (2) automatically download and install, after asking for permission to go online.


答: As of tools you can make use of, you may want to try Pivotal Tracker.</p>


问:
Design patterns - do you use them?
Being an IT student, I was recently given some overview about design patterns by one of our teachers. I understood what they are for, but some aspects still keep bugging me.

Are they really used by the majority of programmers?

Speaking of experience, I've had some troubles while programming, things I could not solve for a while, but Google and some hours of research solved my problem. If somewhere in the web I find a way to solve my problem, is this a design pattern? Am I using it?

And also, do you (programmers) find yourself looking for patterns (where am I supposed to look, by the way?) when you start the development? If so, this is certainly a habit that I must start to embrace.

UPDATE: I think when I ask if programmers do use them, I'm asking if when you have a problem to solve you think "Oh, I should use that pattern".

答:
Whether one recognizes them or not, most programmers do use patterns.

On the day to day work however, one does not start programming with a pattern in mind - one recognizes that a pattern has emerged in code and then names it.

Some of the common patterns are built into some languages - for example, the iterator pattern in built into C# with the foreach keyword.

Sometimes you already know the pattern you will be using as a common solution to the problem at hand (say the repository pattern - you already know you want to represent you data as an in-memory collection).

Title: Design patterns - do you use them?


答:
Learning patterns is not just learning something. You learn what you can do with programming languages. I for myself learned a lot about object-oriented programming just by learning how a pattern works (the composite pattern in this case).

As mentioned by Oded, most programmers use them sometimes without even recognizing it. The beauty of patterns is that you can adress specific problems with a predefined pattern so you don't have to think a lot about architectual things.

Title: Design patterns - do you use them?

Body:
Being an IT student, I was recently given some overview about design patterns by one of our teachers. I understood what they are for, but some aspects still keep bugging me.

Are they really used by the majority of programmers?

Speaking of experience, I've had some troubles while programming, things I could not solve for a while, but Google and some hours of research solved my problem. If somewhere in the web I find a way to solve my problem, is this a design pattern? Am I using it?

And also, do you (programmers) find yourself looking for patterns (where am I supposed to look, by the way?) when you start the development? If so, this is certainly a habit that I must start to embrace.

UPDATE: I think when I ask if programmers do use them, I'm asking if when you have a problem to solve you think "Oh, I should use that pattern".


问:
What is classic object oriented programming?
I heard the phrase classic object oriented programming. Is it different from present object oriented programming, like classic ASP and ASP.net?

答:
I've only heard the term classical OO when used to distinguish between the class based OO you find in Java and the prototype based OO you find in JavaScript. The term doesn't refer to an outdated style.

It is completely unrelated to Classic ASP / ASP.NET where "Classic" means "I really mean ASP and am not using it as a shorthand for ASP.NET".


问:
Should I be concerned that I can't program very fast without Google?

Possible Duplicate:

  Google is good or bad for programmer?

I'm currently in college to be a software engineer, and one of the main principles taught to us is how to learn for ourselves, and how to search the web when we have a doubt.
This leads to a proactive attitude - when I need something, I go get it.

Recently, I started wondering how much development would I be able to do without internet access and the answer bugged me quite a bit. I know the concept of the languages and how to use them, but I was amazed by how "slow" things were without having the Google to help in the development. Most of the problems I have are related to specific syntax.

For example, reading and writing to a file in Java. I have done this about a dozen times in my life, yet every time I need to do it, I end up googling "read file java" and refreshing my memory. I completely understand the code and fully understand what it does, but I am sure that without Google it would take me a few tries to get the code correct.

Is this normal? Should I be worried and try to change something in my programming behaviour?

答:
If - as you seem to indicate - you use Google & the web to gather information you know how to use, and (ideally) you would be able to get from other local sources (such as printed books - provided you had the perfect developer's library), it is IMO fine. Practically all developers seem to do this nowadays (even those of us who have development experience from the pre-Google and pre-internet time). Because when used sensibly, the web indeed gives us an amazing productivity boost, by resolving repetitive and slow tasks for us, such as looking up information in paper-based books and libraries, and ensuring it is up to date.

Syntactic details is a typical thing for me too. Nowadays I can have a task requiring the usage of any of at least 4 different languages, 3 of which I am not a master of. So looking up the specific details like this is regular activity to me. Still, I know enough of each of these languages to use the code examples I find (more or less) the correct way and in the right context.

OTOH, copy-pasting snippets of code googled from the net into production code without fully understanding what and how these do is definitely a Bad Thing which must not be done - else it is bound to backfire sooner or later.

Update

Reading and writing to a file in java. I have done this about a dozen times in my life, yet every time i need to do it, i end up googling "read file java" and refreshing my memory.

I would pretty much do the same, even though Java is my main language at the moment :-) Since I have mostly done server side development in it, I rarely need to do file manipulation. So these things aren't in my (limited) short term memory.

Memorizing the details of specific APIs / frameworks / languages / whatever may give us intellectual satisfaction, but ultimately it is only useful insofar it helps us solving (our own and customers') actual problems. If I haven't needed the nuts and bolts of Java File I/O API(s) in order to solve any problems recently, there is no value in keeping it in memory, and IMO it is entirely logical and useful to replace it with something more useful in my short term memory (keeping only a brief reference to the source of relevant information).


问:
What difference with Android when iOS is not open?
My question may seem silly, but, I've read in many Android books that the better part of Android is Android is open, and iOS is closed.

But, from a programmer viewpoint, who cares about this point? Programmers just care about the platform: is it easy to program in, easy to have help in the network, etc. They don't care about whether the platform is open or closed.

One book had additional information, but I don't understand it much. Since iOS is not open, I’d be able to share my work with others only if Apple allowed it.

So, if you write an app, and need to share, you must have Apple's permission, but not Android's?

Please help me understand this point. I'm preparing for a presentation on Android. And I don't know if I should put this point into my presentation.

答:
The book is talking about the platform being open or not.

Why would you care?

If there is a bug in the framework/platform, if it is open source you could fix it and submit a patch to fix it for everyone. You could add features that you need. You can view the source to see how things are done.

You can't do that with closed source.


问:
Why are statements in many programming languages terminated by semicolons?
Is there a reason that a semi-colon was chosen as a line terminator instead of a different symbol?

I want to know the history behind this decision, and hope the answers will lead to insights that may influence future decisions.

答:
Its about visibility.

Early statement separators were the '.' as in COBOL and new line, carriage return in FORTRAN.

The CR proved limiting in that it makes it difficult to flow a statement over several lines.

Full stop caused a more interesting problem. When you read English text your brain processes the full stops at a subliminal level, you are conscious that a sentence has ended and you can pause for breath but you don't really notice the . that signaled it. Also in many fonts the '.' is the smallest possible character sometimes rendered as a single pixel. Missing or extra periods became the single most common cause of errors in COBOL programs.

So learning from early mistakes ALGOL pick a specific terminator which would allow a statement to flow over several lines, and, picked one that was visible and easily noticed by human readers. The semi-colon being both large and unusual enough in common English not to be processed subconsciously.


答:
Working without internet is a skill. You don't have it, as most developers.

The thing you must ask yourself before being worried is if you need this skill in your life. Chances are, you don't, because at every developer job with Joel Test higher than zero, you will have a fast internet access.

Then, you have a choice:

Either you spend years learning how to work effectively without internet, without IDE (just with a text editor with no syntax highlighting) and even without a high level operating system (i.e. only in console mode).

Or you spend the same time learning things you will really use in your daily work.

The first will help you a lot in a case of some post-apocalyptic world where there will be no IDEs, no operating systems and no internet, and where most developers would be unable to continue their career because of the lack of skills.

The second helps you today, in the world you live, right now, and very probably in the near future.

Title: Should I be concerned that I can't program very fast without Google?

Body:
Possible Duplicate:

  Google is good or bad for programmer?

I'm currently in college to be a software engineer, and one of the main principles taught to us is how to learn for ourselves, and how to search the web when we have a doubt.
This leads to a proactive attitude - when I need something, I go get it.

Recently, I started wondering how much development would I be able to do without internet access and the answer bugged me quite a bit. I know the concept of the languages and how to use them, but I was amazed by how "slow" things were without having the Google to help in the development. Most of the problems I have are related to specific syntax.

For example, reading and writing to a file in Java. I have done this about a dozen times in my life, yet every time I need to do it, I end up googling "read file java" and refreshing my memory. I completely understand the code and fully understand what it does, but I am sure that without Google it would take me a few tries to get the code correct.

Is this normal? Should I be worried and try to change something in my programming behaviour?


答:
It's no more than an ideological point.  If you want normal people (i.e. non developers) with iOS devices to be able to use your iOS app, you have to distribute it via the Apple app store, there is no other way, unless you limit your audience to people with jailbroken devices. If Apple rejects your app, that's it, you're done.

The source code of iOS is not directly available to you to look at, but the APIs are generally pretty well documented.  The source code for Android is, at least theoretically, available, but if you need to start looking through it, it's an indication that the documentation is crap.

Title: What difference with Android when iOS is not open?

Body:
My question may seem silly, but, I've read in many Android books that the better part of Android is Android is open, and iOS is closed.

But, from a programmer viewpoint, who cares about this point? Programmers just care about the platform: is it easy to program in, easy to have help in the network, etc. They don't care about whether the platform is open or closed.

One book had additional information, but I don't understand it much. Since iOS is not open, I’d be able to share my work with others only if Apple allowed it.

So, if you write an app, and need to share, you must have Apple's permission, but not Android's?

Please help me understand this point. I'm preparing for a presentation on Android. And I don't know if I should put this point into my presentation.


答:
It depends on what you are googling for.

If you are googling for precise syntax definitions or some obscure reference to apply to your solution that's okay.  without Goole and with time and books you will get that solved

If, on the other hand you are googling HOW to solve the problem, you have a problem

EDIT: when I say 'HOW to solve the problem, I mean along the lines of the 'can I have the code' posts, rather than 'I have an idea, but need clarification'


答:
In short it depends on what kind of development you are doing.  If it's (limited to) basic windows/web development then it may not be cost effective.  However if you need to support a wide field of development activities (SharePoint, Web, Desktop) that may use other tools such as SQL Server it may pay for it self.

As an example I currently work for a consulting company and I am supporting projects that are developing SharePoint applications for WSS 3.0 on Win 2003, a WPF application, and a ASP.NET MVC app backed by oracle.  The MSDN subscription helps in that I can get an OS license to run a SharePoint VM for dev purposes.  I've also got a different VM setup for development of the MVC project.  If you looked at purchasing a license for each of those OS's you would most likely be quickly pushing the basic MSDN price.  Add in a new project that requires SQL Server and you are probably there.

I am aware of a group that is trying to convince their manager that MSDN will be cheaper in the long run for them with setting up a proper SharePoint development activity then trying to purchase individual licenses.

Something else to consider is the fact that having access to try out the various MS products (versus a short term demo) and what that may or could mean to your future product development may prove useful.

Title: What does an MSDN subscription offer?

Body:
I'm curious because I notice that the Ultimate subscription costs $12,000... for one year (after that, it's $3,800 to renew). Looking at the subscription chart, you do get quite a bit of software that is normally expensive by itself.

Is the package meant for 1 person or is it meant for like a business-type bundle of some sort? If it's the latter, I can kind of understand that, but I can't fathom where anybody is going to have 12 grand to plop down on something that only lasts 12 months.

Anyway, yeah, my question is, is this a good deal to anyone at all? Maybe it's just me not having any industry experience and this is actually a steal and millions of companies should be buying it right now, but I just can't personally picture this being worth the money.


答:
I think this is completely normal.

You can not overestimate the influence of the internet and  effective search engines on productivity!

Before we had the internet, we had to rely on books and other printed source of information to look things up. Boy, was that slooooooow...
(ok, yes, I am old - not only do I remember the time before Google, I even remember the time before the internet!)

Regarding your example of reading and writing files in Java: I have done this more often than a dozen times in VBA, but if I wanted to do it now, I would need to look up how to do it anyway. I wouldn't need that in C#, because that's what I program in right now. But VBA is not something I use on a daily base (thank God), so the knowledge is not that present in my mind.

If you are doing it every single day and after two weeks you still need to look it up, I would say that you have a problem with mid term memory and should worry (and go see a doctor about it, perhaps). But if you need a refresher on things you have learned some time ago, but do not remember right now, that's ok.


答:
As implied by the answer pdr linked: design patterns are names given to things people were doing anyway, intended to make it easier for people to discuss those things.

In general it's worth learning them when starting out, because they give you some insight into solutions people have found to work, so you can build on years of experience, and trial & error.

The discussion of motivating problems included with patterns may give you insight into good ways to attack your problem in the first place, but unless your pattern knowledge lets you recognize there is a well-known existing solution, you still need to focus on just solving the problem first.

If it turns out to use one or more existing patterns then great, you have ready-made names that will make it easier for others to understand your code.

Title: Design patterns - do you use them?


答:
Generally speaking, no. There are times when patterns emerge from my code, but in general, I don't look for them and I certainly don't say "Oh, the Bridge Pattern would solve my problem!".

Here's the thing. Most patterns are abused and misused without people ever considering if they're good design. Patterns are not atoms. Code is not comprised of X permutation of patterns. Not to mention that not all patterns are actually good ideas, or that some languages have language-level solutions that are vastly superior to some patterns.

Title: Design patterns - do you use them?


问:
False friends? Keyword "static" in C compared to C++, C# and Java
To me, the use of the keyword static in C and languages like C# and Java are "false friends" like "to become" in English and "bekommen" in German (= "to get" in English), because they mean different things.

In C static means, that the function or variable is only accessible via functions inside the same source file, comparable to private functions and members in C++, Java and C#.

In C++, Java and C# static means, that the methods are not members of a class instance, but effectively are more or less like C functions plus namespace.

IMHO these two concepts are quite different, so why did the designers of C++ and later Java and C# choose the static keyword for that behaviour? Is there a logical connection that I miss?

EDIT
I know, that static in C does not govern accessability in a way similar to private in C++, but can be used in that way, see https://stackoverflow.com/a/1479639/124983

答:
Notably, C++ has both uses of static, and I think there's a third somewhere.

Generally, I think that the C use of static does not correspond at all to any English usage of the word, whereas I think that static as a static member variable, for example, makes a lot more sense.

Remember that as a language designer, you have a fair incentive to introduce fewer keywords into the language, to disallow less code- especially when you're trying to be source-compatible with C, as in C++, and the static keyword already existed, so they couldn't break any C programs trying to compile as C++ by re-using it.

Edit: I knew there was a third. C has function-level static variables. The static member is just a scoped version of this functionality. Therefore, both uses of static originate from C.


答:
do you use them?

Yes, experienced programmers definitely do. You can avoid using most design patterns (excluding simple singleton stuff) for now; but the more you program and the more complex systems you build, the more you will feel the need to use design patterns. If you still avoid it, you will begin to feel the pain when you have to expand your system and change it as per new requirements.

If somewhere in the web I find a way to solve my problem, is this a
  design pattern?

Not necessarily. A design pattern refers to a specific way to design classes, their behaviours and interactions to achieve a specific goal (or avoid a specific problem). What you may have come across may not really be a design problem but a specific sequence of steps to program a certain API. For example: there is a certain sequence to establishing a socket connection. Do it wrong and your socket wont communicate. That sequence of steps does not constitute a pattern.

do you (programmers) find yourself looking for patterns

Yes. Design patterns embody the  "prevention is better than cure" axiom. If you can spot a particular upcoming design problem beforehand, you can prevent massive redesigns to accommodate changes later. So it pays to know design patterns beforehand and look for places where you need to use them as you build your application.

where am I supposed to look btw?

Since you are a student you have probably not seen the typical problems that inspire design patterns. I strongly recommend that you look at Head First Design Patterns. They first present a design problem and then show how a particular pattern can solve/avoid it.

Title: Design patterns - do you use them?


答:
Recent research suggests that the internet has completely changed the way we memorise things, as a species, not just in programming. Rather than memorising a whole piece of information, we are learning to remember how to find it (for example, I just Googled "memory google" to find that link). This is not a bad thing, it's a more efficient use of our limited brain-spaces. Think of it as a complex version of a database index.

I'm old enough to remember days when I had the entire MSDN library, in book form, piled on my desk. It was big. And it wasn't even close to the full collection of books I had. But, because it was hard-work trudging through those books, I memorised a lot of it. It was imperative, to be productive.

Nowadays, I don't have to remember anything, I need to hone my Googling skills. If that doesn't work, I can usually get an answer to my question from Stack Exchange in minutes, even if I have to ask and wait for a response.

If it's something I have to do 20 times a day then I'll soon learn to do it without even thinking, let alone searching. But if it's something I do monthly then it's not an efficient use of my brain to remember it. Rather, it's useful for me to know how to find it -- keep a link to a blog or even write some notes in the corporate wiki.

But, if I had to go back to working without that information available, I've no doubt that I could. It's highly likely you could too. We adapt like that, as a people. This is exactly how we've advanced as a race. ("It is not the strongest of the species that survives, nor the most intelligent, but the one most responsive to change." - Darwin.)

Just be really thankful that we probably won't have to.


答:
C++ took it from C, because C++ likes to reuse existing keywords instead of introducing new ones, to minimize breaking existing code.

Java and C# then took it from C++.

Title: False friends? Keyword "static" in C compared to C++, C# and Java

Body:
To me, the use of the keyword static in C and languages like C# and Java are "false friends" like "to become" in English and "bekommen" in German (= "to get" in English), because they mean different things.

In C static means, that the function or variable is only accessible via functions inside the same source file, comparable to private functions and members in C++, Java and C#.

In C++, Java and C# static means, that the methods are not members of a class instance, but effectively are more or less like C functions plus namespace.

IMHO these two concepts are quite different, so why did the designers of C++ and later Java and C# choose the static keyword for that behaviour? Is there a logical connection that I miss?

EDIT
I know, that static in C does not govern accessability in a way similar to private in C++, but can be used in that way, see https://stackoverflow.com/a/1479639/124983


答:
C static does not govern accessibility, and isn't analagous to private in the way you suggest.

At file scope, it governs availability of the name (linker symbol), not the thing - you can pass a pointer to a static function or global from the translation unit where it is defined to code in another file, and it will work fine.

The C++ way of doing this (as DeadMG says, the C way is still available too) is to use an anonymous namespace.

In function scope, it essentially replaces the local variable with a global which is only accessible (by name again!) inside that function - this is identical in C++ (so, there isn't a more C++y  way of doing it).

As for why C++ used the static qualifier for class members; it's probably right to say that this is to minimize the number of new keywords introduced. (Note the recent re-use of auto for comparison).

Calling per-class data static (so implicitly per-instance data are dynamic) seems fairly intuitive to me, but since I don't remember the process of forming that intuition, I can't really comment objectively on whether it made sense when starting out.


答:
When I was a novice programmer, I loved design patterns. I didn't just use design patterns. I inflicted them. Wherever and whenever I could. I was merciless. Aha! Observer pattern! Take that! Use a listener! Proxy! AbstractFactory! Why use one layer of abstraction when five will do? I've spoken to many experienced programmers and found that just about everyone who reads the GoF Book goes through this stage.

Novice programmers don't use design patterns. They abuse design patterns.

More recently, I find that keeping principles like the Single Responsibility Principle in mind, and writing tests first, help the patterns to emerge in a more pragmatic way. When I recognise the patterns, I can continue to progress them more easily. I recognise them, but I no longer try to force them on code. If a Visitor pattern emerges it's probably because I've refactored out duplication, not because I thought ahead of time about the similarities of rendering a tree versus adding up its values.

Experienced programmers don't use design patterns. Design patterns use them.

Title: Design patterns - do you use them?


答:
In C++, static has the following four uses:

Global (file-level) function and variable declarations: with static, you are specifying internal linkage. That means that the symbol is only used in that one compilation unit (.cpp/cc/whatever file, not a header). This is what you are referring to as "private".

Local variables: Static storage duration specifies that the variable should retain its value between function calls.

Data members: Static data members are shared between the instances of the class (i.e. there is only one copy of the member). This is akin to C# and Java static.

Member functions: Static member functions are member functions that don't have an implicit this pointer; they can be invoked without an instance. This is also much like in C# or Java.

So, as you can see, they dropped two of the above meanings. For scoping it is quite understandable why: both C# and Java (and even C++) relies on namespaces to do that. C++ probably has the internal linkage feature for backwards compatibility. Ditching static local variables is probably two-folded: for once, it can be difficult to fully understand its consequences, and these languages aim for simplicity. Second, both Java and C# has a garbage collector which (I can imagine) causes difficulties to implement such behavior.


答:
So, if you write an app, and need to share, you must have Apple's
  permission, but not Android's?

Yes, in case of Android you can just share the APK file and anyone can install it. Google Play (f. Android Market) is just for convenience. On the other hand the on iOS, Apple AppStore is the only way to distribute your software to the people. You can share it with you dev team using iOS Provisioning, but that's quite complicated and limited. I'm not really counting jailbreaking as an option, as most people aren't wiling to do it because of legal and technical risks involved.

Programmers just care about the platform: is it easy to program in,
  easy to have help in the network, etc. They don't care about whether
  the platform is open or closed.

Open platform translates to more 3rd party tools, more involved community and better community documentation. And it's all googleable.

It's also about freedom. In case of iOS you have to develop using Apple SDK with Apple Xcode on Apple machine, and have an account in Apple Developers Program. In case of Android you can develop on your favorite OS, on you favorite brand of computer, using your favorite IDE.


问:
Scaling Scrum within a group of 100s of programmers
Most Scrum teams lean toward 7-15 people ******, though it's not clear how to scale Scrum among 100s of people, or how the effectiveness of a given team might be compared to another team within the group; meaning beyond just breaking the group into Scrum teams of 7-15 people, it's unclear how efforts between the teams are managed, compared, etc.

Any suggestions related to either of these topics, or additional related topics that might be of more importance to account for in planning a large scale SCRUM grouping?

****** In reviewing research related to the suggested size of software development teams, which appears to be the basis for the suggested Scrum team size, I found what appears to be an error in the research which oddly appears to show that bigger teams (15+ ppl), not smaller teams (7 ppl) are better.

UPDATE, "Re: Scrum doesn't scale": Made huge amounts of progress personally researching the topic, but thought I'd respond to the general belief of some that Scrum doesn't scale by citing a quote from Succeeding with Agile by Mike Cohn :

Scrum Does Scale: You have to admire the intellectual honesty of the earliest agile authors. They were all very careful to say that
  agile methodolgies like Scrum were for small projects.  This
  conservatism wasn’t because agile or Scrum turned out to be unsuited
  for large projects but because they hadn’t used these processes on
  large projects and so were reluctant to advise their readers to do so.
  But, in the years since the Agile Manifesto and the books that came
  shortly before and after it, we have learned that the principles and
  practices of agile development can be scaled up and applied on large
  projects, albeit it with a considerable amount of overhead.
  Fortunately, if large organizations use the techniques described
  regarding the role of the product owner, working with a shared product
  backlog, being mindful of dependencies, coordinating work among teams,
  and cultivating communities of practice, they can successfully scale a
  Scrum project.

SOURCE: (ran across the book thanks to Ladislav Mrnka answer)

答: It's not possible to have effective scrum with such a big group. Even with twenty-something you begin to struggle. You have to divide these 100 people into much smaller task groups, which each group having their scrum. Then you can have scrum of team leaders/representatives. This is known as the scrum of scrums. </p>


答:
If Google doesn't accept your app for the play store, or you don't like their conditions, you could still offer it through alternative means, e.g. Amazon Market, AndroidPIT etc. or just sell it on your own website (*). Additionally, since Apple has strict requirements regarding content etc., and enforces them, your app is more likely to be rejected by Apple than by Google.

Android in general allows your app to dig deeper into the system. On iOS, your app simply cannot get the permission e.g. to kill other apps.

(*) Gameloft offered their Android games only through their website for a long time, so it's not a purely hypothetical option.


答: yes, most programmers I've ever encountered use the most common pattern there is, the Big Ball of Mud. They usually start out with well-designed architectures, but usually end up here, especially if they start to think "we must use design patterns" all over the place and refactor mercilessly.</p>

Title: Design patterns - do you use them?


答:
I did programming in the "pre-Internet" days. Back then, I had several books on hand to look up bits of info I needed for MASM and C. I'd look in the table of contents or index and find what I needed. If it wasn't in one of my books I'd have to go to the bookstore and buy one that did or, in some cases, order one through the store and wait for it to be delivered.

I'd also communicate with other programmers via Compuserve, Genie or other paid services, Usenet or on bulletin board systems (FIDOnet, etc.). It wasn't that much different than SO or other online forums although it wasn't nearly as efficient as doing a Google search today.

So, the Internet has made programmers more efficient because more information is available and more quickly. You don't need to lug around a bunch of books or try to search through tons of unconnected text from dozens of different sources.


答: I would assume that a longer download means they are more likely to get tired of waiting and try something else. People are impatient. The sooner they are using and loving you app the better. </p>

Title: How Does Download Size Affect Potential Users of Your Product

Body:
Does anyone know (or, I guess, I have gut feeling about) how the download size of a software product affects potential users, bandwidth not withstanding?

For example: Does a bigger download make them
   believe that is it more full-featured
   than it is (like huge .NET Runtimes
   if deployed with your package)?

Reason is, I'm developing a VSTO add-in where there is my add-in (small MB), the VSTO run-time, .NET runtime, and Primary Interops. This could make it more than 70 MB in total size, just for an add-in that does a couple of things well. But that's all they are - just a couple of things.

With VSTO deployments, I know I could deploy a smaller package size by assuming they've got the .NET runtime (and when they don't, initialize the download/install of that, but it seems like a clunky way to make just an ass out of me).

What I really want is for people to just download the app (the trial version) to see if they like it. Is there some kind of magic happy threshold - like users of non-big name apps are more likely to download something that is under 20 MB than 50 MB?


答:
If you have single project with 100s of people and you want to jump directly into agile and especially Scrum you are most probably performing project suicide.

Agile development and Scrum is skill as any other. If you want to use it you must start with small project. Once you master small project you can start scaling by small steps. The best way to say that agile is not working is to convert big project from plan driven approach to agile approach without any previous experience with scaling agile.

Scaling agile is about incorporating plan driven methods on higher level. You cannot scale Scrum infinitely. The more you scale it the more plan driven mechanism will be needed. There is something called Scrum of Scrum but that is exactly something you can do only if you master pure Scrum with small team. Scrum of Scrum has also its limits - I guess something like 5-6 teams / up to 40 people.

Edit:

The last assumption comes from a lot of sources including CSM and CSPO trainings, books like Succeeding with Agile and Balancing Agility and Discipline and my own experience when participating on both small Scrum team (up to 5 people) and bigger team with 15+ people divided into three teams working on the same project. The bigger the project is the more agility on higher level will be replaced with some old plan driven techniques.

Even trainer on my CSM training claimed that scaling Scrum is one of the biggest challenges the Scrum itself faces.

Title: Scaling Scrum within a group of 100s of programmers

Body:
Most Scrum teams lean toward 7-15 people ******, though it's not clear how to scale Scrum among 100s of people, or how the effectiveness of a given team might be compared to another team within the group; meaning beyond just breaking the group into Scrum teams of 7-15 people, it's unclear how efforts between the teams are managed, compared, etc.

Any suggestions related to either of these topics, or additional related topics that might be of more importance to account for in planning a large scale SCRUM grouping?

****** In reviewing research related to the suggested size of software development teams, which appears to be the basis for the suggested Scrum team size, I found what appears to be an error in the research which oddly appears to show that bigger teams (15+ ppl), not smaller teams (7 ppl) are better.

UPDATE, "Re: Scrum doesn't scale": Made huge amounts of progress personally researching the topic, but thought I'd respond to the general belief of some that Scrum doesn't scale by citing a quote from Succeeding with Agile by Mike Cohn :

Scrum Does Scale: You have to admire the intellectual honesty of the earliest agile authors. They were all very careful to say that
  agile methodolgies like Scrum were for small projects.  This
  conservatism wasn’t because agile or Scrum turned out to be unsuited
  for large projects but because they hadn’t used these processes on
  large projects and so were reluctant to advise their readers to do so.
  But, in the years since the Agile Manifesto and the books that came
  shortly before and after it, we have learned that the principles and
  practices of agile development can be scaled up and applied on large
  projects, albeit it with a considerable amount of overhead.
  Fortunately, if large organizations use the techniques described
  regarding the role of the product owner, working with a shared product
  backlog, being mindful of dependencies, coordinating work among teams,
  and cultivating communities of practice, they can successfully scale a
  Scrum project.

SOURCE: (ran across the book thanks to Ladislav Mrnka answer)


答:
Scrum is intended for small teams, because the authors of scrum found that small self-organizing teams tended to be very effective in their experience.  This makes sense if you consider the lean principle that hand-offs are wasteful and larger teams tend to necessitate hand-offs.

The general take on how to manage larger groups is to create a "scrum of scrums", in which case each team copes with their own sub-project, and then a member from each team represents the sub-project in a team of similar representatives from other sub-projects.  This scales up as a pyramid:

```<code>           MT (Master Team for full project)
          /|\
         / | \
        /  |  \
      T1   T2  T3 (Teams of Sub-projects)
     /|\
    / | \
   /  |  \
 ST1 ST2 ST3 (Teams of sub-sub-projects)
</code>```

Coordination of this sort of thing is tricky, but it has been done.  The notion of effectiveness can be seen through the visibility inherent is scrum--burn downs and the like.

Really, if your project is so big that you need hundreds of developers, the odds are against you.  You need to decompose it into workable projects that can be understood by those working on them.

Body:
Scrum is intended for small teams, because the authors of scrum found that small self-organizing teams tended to be very effective in their experience.  This makes sense if you consider the lean principle that hand-offs are wasteful and larger teams tend to necessitate hand-offs.

The general take on how to manage larger groups is to create a "scrum of scrums", in which case each team copes with their own sub-project, and then a member from each team represents the sub-project in a team of similar representatives from other sub-projects.  This scales up as a pyramid:

           MT (Master Team for full project)
          /|\
         / | \
        /  |  \
      T1   T2  T3 (Teams of Sub-projects)
     /|\
    / | \
   /  |  \
 ST1 ST2 ST3 (Teams of sub-sub-projects)

Coordination of this sort of thing is tricky, but it has been done.  The notion of effectiveness can be seen through the visibility inherent is scrum--burn downs and the like.

Really, if your project is so big that you need hundreds of developers, the odds are against you.  You need to decompose it into workable projects that can be understood by those working on them.


答:
I find myself on your description, and what I can say is because of that I could get a deadline in a c++ project without any experience in the language itself.

As you pointed, when I needed to read a file in c++ I googled it and got to several pages, thanks to some OO knowledge, I could find the most accurate solution to my problem, even had the luxury to find logical errors in one of the proposed solutions.

What you are doing with google, you can replace with a cheat-sheet, Eclipse has a very nice User Assistance section in the wizard when you do ctrl+n, that helps you to create your own cheat-sheet, in that way you can code once and paste several times.

Like some answers pointed out, Internet boosts your productivity! Don't be afraid to use it :)


答:
I have a book about the design of C++ by Bjarne Stroustrup (the inventor of C++). I don't have it right here so I can't lookup the exact quote right now, but in it he admits that when he added static to C++, he didn't fully understand what it meant in C. So that's why in C++ it has a different meaning than in C.

Java and C# inherited the meaning from C++.


问:
How do you track bugs in your personal projects?
I'm trying to decide if I need to reassess my defect-tracking process for my home-grown projects.  For the last several years, I really just track defects using TODO tags in the code, and keeping track of them in a specific view (I use Eclipse, which has a decent tagging system).

Unfortunately, I'm starting to wonder if this system is unsustainable.  The defects I find are typically associated with a snippet of code I'm working on; bugs which are not immediately understood tend to be forgotten, or ignored.  I wrote an application for my wife which has had a severe defect for almost 9 months, and I keep forgetting to fix it.

What mechanism do you use to track defects in your personal projects?  Do you have a specific system, or a process for prioritizing and managing them?

答:
I use ToDo List program, an open source code from codeproject

http://www.codeproject.com/KB/applications/todolist2.aspx

Very nice and with many features.


问:
How much should I pay to Microsoft when I am selling a desktop & Web base software built on VB.NET using MS SQL 2005 Express Edition?
Can I distribute the MS SQL 2005 Express edition along with my application to the customer?</p>

答:
Can i distribute the MS SQL 2005 Express edition

You need to register for the free redistribution rights in order to do so. The contact details are here. Not doing so may mean you are doing something illegal.

From the SQL Server 2005 express download page:

Building and shipping applications with SQL Server Express? Sign up for free redistribution rights here.

You don't have to pay Microsoft when you sell software created using their tools. You may have to pay if you wish to redistribute the tools.


问:
When is a requirement considered complete?
Which elements must a requirement contain that it can be considered complete? Or if this works better - which questions should I ask about a requirement to find out if it is complete. I am not talking about the implementation of the requirement but the requirement itself.

I am asking this from the perspective of an analyst who wants to make sure that his requirements are complete before passing them on to the design team.

答:
Does this requirement properly & Fully capture the business needs?

But, Personally I would have the business review the requirements before passing it off to design.


答:
As a developer who occasionally has to do work in relatively unfamiliar languages on computers that are airgapped from the internet for security reasons I'm probably better able to comment on this than most people, and I agree the general sentiment of most of the other answers.

A decent IDE's autocomplete is able to find about 95% of what I need in the standard class libraries.  Walking to/from a networked computer (and occasionally taking notes/making a printout) only costs me an hour or two of reduced productivity per month of coding.

Trying to memorize massive class libraries just isn't worth the effort expended.  Spending a few hundred hours learning something else would have a much higher return on the time expended.


答:
To be considered complete, each requirement must be (at minimum):

Unambiguous - each requirement can only mean one thing and can only be interpreted one way.

Atomic - each requirement cannot be broken down into multiple requirements.

Testable - each requirement can be shown to have been met or not met via some form of testing.

You'd be surprised how good your requirements turn out by just following these three guidelines at all costs.

Also, be sure to write a rationale for each requirement.  This is very important and useful down the road when someone wonders why a particular requirement was created.

And remember, the requirements should describe WHAT the software will do, not HOW it will do it.  The HOW should be left for the design team.

Title: When is a requirement considered complete?

Body:
Which elements must a requirement contain that it can be considered complete? Or if this works better - which questions should I ask about a requirement to find out if it is complete. I am not talking about the implementation of the requirement but the requirement itself.

I am asking this from the perspective of an analyst who wants to make sure that his requirements are complete before passing them on to the design team.


答: When it's launched to production and verified by the PM. I know that's not what you're looking for because you want to ensure the requirements are correct before design, but that's not the way it works in the real world. Requirements are missed, misunderstood by the engineers, mis-stated by product, vaguely stated by product, vaguely understood by engineers, etc. And sometimes that's not obvious until code starts getting written, or until an integration test starts failing, or until the PM sees the feature demoed and says, "This isn't the right feature."</p>


答:
there are several things that should true for requirements to be complete.

Does the requirement relate directly to achieving part of the business process?

Is the requirement verifiable when implemented?

Does the requirement express the idea as simply as possible?

Is every part of the business process defined by at least one requirement?

If all of these are true you can be fairly certain that a requirement is complete. Though you can't be 100% sure until your designers/programmers look at them and understand them the same as you do.


答:
Requirements rarely completes, usually it evolves and changes.

As is told in the famous book Pragmatic Programmer, From Journeyman to Master by Andrew Hunt, David Thomas;

The Requirements Pit

Many books and tutorials refer to requirements gathering as an early phase of the project. The word "gathering" seems to imply a tribe of happy analysts, foraging for nuggets of wisdom that are lying on the ground all around them while the Pastoral Symphony
  plays gently in the background. "Gathering" implies that the requirements are already there—you need merely find them, place them in your basket, and be merrily on your way.

It doesn't quite work that way. Requirements rarely lie on the surface. Normally, they're buried deep beneath layers of assumptions,
  misconceptions, and politics.

I am not really sure if there is any point at which you can tell that requirement are complete.

I am asking this from the perspective of an analyst who wants to make sure that his requirements are complete before passing them on to the design team.

It purely a personal or business choice, many projects starts with a high level idea of what they want, and will evolve by itself to reach the final stage. Some cases you might  need to sign some contract which will state the basic set of requirements. so, it always depends.

When it comes to requirements the only important thing is that, you should be prepared to act based on the change.


答: This sort of thing is why the UNIX world has man pages... the internet has just made this sort of thing better. </p>


答:
You should have a definition of done.

There is a decent blog post on the subject, but I usually use the definition of definition of done (yeah) from the official scrum guide.

Definition of “Done”

When the Product Backlog item or an Increment is described as “Done”, everyone must
  understand what “Done” means. Although this varies significantly per Scrum Team, members
  must have a shared understanding of what it means for work to be complete, to ensure
  transparency. This is the “Definition of Done” for the Scrum Team and is used to assess when work is complete on the product Increment.

The same definition guides the Development Team in knowing how many Product Backlog items
  it can select during a Sprint Planning Meeting. The purpose of each Sprint is to deliver
  Increments of potentially releasable functionality that adhere to the Scrum Team’s current
  Definition of “Done.”

Development Teams deliver an Increment of product functionality every Sprint. This Increment is useable, so a Product Owner may choose to immediately release it. Each Increment is additive to all prior Increments and thoroughly tested, ensuring that all Increments work together.

As Scrum Teams mature, it is expected that their Definition of “Done” will expand to include more stringent criteria for higher quality.


答:
There is nothing wrong with Googling for answers, but it is not optimal to retrieve information that you have already found. Here's some suggestions:

Develop your own library in each language. Then, when you want to write to a file, you can use your library. And, you can even use it to look up the syntax.

Create a "Brain Backup" system. I use Evernote and find it wonderful. Here's more ideas: https://softwareengineering.stackexchange.com/questions/113462/how-do-you-manage-all-of-the-information-you-have-learned-and-found

Get good at memorizing. Memorization is a skill that is not taught in school. It is hardly critical to being a great programmer, but it is better to remember something than having to Google for it. We can greatly improve our skill at memory the same way that we improve all of our other skills: learning effective techniques and practicing.

By the way, I found this interesting tool to improve brain performance on the SPOJ site: Improve your brain health and performance


答:
Believe you're missing the point, that being languages naturally bootstrap from the exchange that results from their use, and to believe that's not the case is a misunderstanding of the nature of languages.

Even before the internet, computers, or even written word - people or "peopleware" used natural forms of communication which resulted in a dialog that bootstraps the exchange and development of any logic based system.


问:
Facing quality issues
A workforce management software has complex GUI (for example values in a page depends on the status (closed or open) of other pages). Only latest and near past development has test coverage. During our last release, we received lots of bugs from customer in-spite of 2 weeks of testing Sprint. We don't have dedicated test team. The developers does the unit test and User acceptance test. Every day triggers automated regression test.

I am afraid the developers are not testing the entire workflow because its time consuming also not able to automate it because of its complexity. Any suggestions? The legacy code (15 years of development) has less code coverage. How can I improve quality?

Note: Now not possible to hire testers to have independent test team.

答:
There is no scientific way with which you can guarantee quality without allocating resources in your plan, preparing comprehensive test cases and executing those cases.

Face the fact that the system has issues and start a project to fix it. Define test cases that cover the scope of your project's responsibilities accurately. It may be the case that your are not responsible for the legacy system. Make the management aware of this.
Construct small teams that could work on entire flows. The individual developer may not be familiar with the entire flow, so your small teams should be constructed with that in mind.

Title: Facing quality issues


答:
Well you don't strictly need a dedicated test team, you can have your developers also develop the tests. It's not the best, and of course, when they're testing they're not developing. And switching back and forth carries some overhead with it. But you can double up. All it takes is time.

Having daily automated regression testing is good. The fact that it still let a lot of bugs come through means your tests aren't worth much. They need to be further developed. And 2 weeks to develop test scripts for a complex system isn't much. There's a reason people get hired full time for this. How long did it take to develop? It'll take about that much time to fully test it. Otherwise, expect to spend 80% of your time debugging (that's 4 times as long as development).

But fix the incoming bugs first. Log them, and develop test cases into the regression test. When they have time, the developers should work on developing the test cases. Don't be afraid to get them extra hardware to mock input.

Title: Facing quality issues

Body:
A workforce management software has complex GUI (for example values in a page depends on the status (closed or open) of other pages). Only latest and near past development has test coverage. During our last release, we received lots of bugs from customer in-spite of 2 weeks of testing Sprint. We don't have dedicated test team. The developers does the unit test and User acceptance test. Every day triggers automated regression test.

I am afraid the developers are not testing the entire workflow because its time consuming also not able to automate it because of its complexity. Any suggestions? The legacy code (15 years of development) has less code coverage. How can I improve quality?

Note: Now not possible to hire testers to have independent test team.


问:
What do you use macros in your editor for?
My editor of choice is Notepad++. It has macro capabilities, but as much as I think, I don't see how can I use it for anything.

Do you use macros in your editor that have made your work easier? (for general use I mean)

答:
I use them for pre-formatting SQL. For example, I have one macro that will surround a line with single quotes and then put a comma at the end. When I paste 50-100 IDs I can apply the macro to the end of the file, then copy-paste the result into a query. This one is also useful for non-SQL purposes.

I have a few similar macros that turn a single line into an INSERT statement for specific tables. It makes creating INSERT scripts much easier.

Most of my macros involve formatting the begining or end of the line in some way, and usually for data, not actual code. The details of your daily tasks will determine if there is anything simple and repetitive enough to be turned into a macro. I've gone for long periods on projects where there simply weren't many tasks that were worthy of editor macros.


答:
It sounds like the complexity of the legacy system is such that none of the developers really understand yet all the dependencies and coupling.  In being assigned user stories they are modifying code that is causing bugs in other areas and functionality because of this unfamiliarity.

This is a problem that in the short term can only be solved by setting aside additional hours for user acceptance testing for every user story.  Without a dedicated tester this will significantly slow down development time.

In the long term however, refactoring and lowering coupling along with gradual incorporation of unit tests will help the software become more stable.

You have stated several times already that hiring a dedicated tester is not possible, but it is important.  Try to convince management that it is a good idea.  Testers cost less money than developers, so if a developer is performing the user acceptance testing then you can argue that the manager is paying too much money for testing work per hour.  If you think about it, hiring a tester will save the boss money.

Title: Facing quality issues


问:
Bug reopen vs. new
A bug was opened, fixed, verified and closed. A month later, it showed up again in a subsequent version after several iterations without any regression.

Provided the bug characteristics are the same, would you reopen the existing bug ID or open a new one with a link to the closed bug?

答: Characteristics do not equal causes. The new bug could have a different underlying reason, even though it appears to be the same. So, open a new bug and point it to the old one to help the developer.</p>

Title: Bug reopen vs. new