答:
From management's perspective, there's nothing wrong with the system and you are just complaining because [you just want to rewrite it/you don't understand what previous engineers did/you want your job to be easy]. A bit of a straw man, but when someone at the top sees that things are working fine right now, they're disinclined to see a crisis where you do (I'm sure there's a climate change allegory in there somewhere...).

To some extent, they have a point. Management sees problems when releases go well beyond their original estimate, estimates seem too high for the work being done, "this is impossible with our existing code base", and high occurrences of bugs slipping past QA. If things are purring along nicely, it's easy to pat you on the head and tell you to do your best, because it's not affecting the bottom line.

What to do depends on your organization and the software itself. Fundamentally, though, I suggest documenting every complication that comes up as a result of bad legacy code. When estimating tasks, make it clear to management why you think it will take that long, with detailed explanations about what aspects of the old code base are adding this extra cost. When bugs are introduced into the code, include the reasons why this bug was able to slip in, and how issues in the old code base are responsible.

I'd suggest phrasing your concerns to the stakeholders in a way that suggests the software has outgrown its original design and is now problematic to continue enhancing.


问:
n-layers architecture design, really worth the effort?
I was building an application in .Net for almost a year (almost alone), I took the decision to build it with a 3-layer design. Recently when finished the project, I analyzed if the effort of creating this application with layer design in mind really compensate for the "benefits" obtained implementing such design.

Out of port the desktop application to web without any major code rewrite and to be almost database-agnostic; I don't see any further benefits of this.

Any experiences, and thoughts?

答:
Layers for the sake of having layers is a common problem. I've seen a number of services and applications that were technically n-tier but were very guilty of violating principles like DRY, separation of concerns and the like. For example, I've worked with apps that had upwards of 10 object creation steps between the UI and the DB, 30+ different DLLs with redundant functionality and so forth.

Now, there is a huge advantage if you can successfully separate concerns and avoid redundant, dependent and convoluted code. It makes the program easier to test, enhance and maintain. It would be nice if this was done more often rather than 'cargo cult' n-tier layers.

ContentLicense: CC BY-SA 3.0


问:
Why should we use low level languages if a high level one like python can do almost everything?
I know python is not suitable for things like microcontrolers, make drivers etc, but besides that, you can do everything using python, companys get stuck with speed optimizations for real hard time system but does forget other factors which one you can just upgrade your hardware for speed proposes in order to get your python program fit in it, if you think how much cust can the company have to maintain  a system written in C, the comparison is like that:
for example: 10 programmers to mantain a system written in c
and just one programmer to mantain a system written in python,
with python you can buy some better hardware to fit your python program, I think that low level languages tend to get more cost, since programmers aren't so cheaply than a hardware upgrade,
then, this is my point, why should a system be written in c instead of python?

答: There are some systems that link in C directly.  Sure you can proxy your function calls and embed an interpreter, but I can do that with nearly any language.</p>

ContentLicense: CC BY-SA 2.5


问:
How quickly is the silent IE upgrade likely to propagate to end users? What about managed corporate IT infrastructures?
According to this article from the BBC and this post on Microsoft's Exploring IE Blog, Microsoft has planned to automatically upgrade Windows XP, Windows Vista, and Windows 7's IE to the latest version.

Microsoft has stated that they will also allow people to opt-out of this update through the use of the The Internet Explorer 8 and Internet Explorer 9 Automatic Update Blocker toolkits and will respect any previous declined automatic updates. I assume managed corporate IE managers can also block whatever they want.

Microsoft's blog post states that the release will begin in Australia and Brazil to be "scaled up as time goes on."

I'm wondering, from the perspective of a web designer, how rapidly these upgrades are likely to be propagated to average end users, but also especially those in tightly-regulated corporate IT infrastructures. Given best (or common ;) practices in the corporate world, as well as average end-user behaviour, how soon can I stop investing a significant amount of time in backwards-compatibility with IE6 and 7?

答:
Insofar as the ancient question "what browsers should I support" the only good answer is "look at your traffic stats; combine with understanding of expense of what to support and make a rational decision." Anything else is ineffective.

My take on the recent Microsoft action is it is more fluff and PR than anything real. The folks who are still on IE6 are there either out of total ignorance -- which this might help, inability to upgrade (pirated XP / low bandwidth) or, in the corporate case, compatibility angles. I can't think of a corporate IT manager who wants to support IE6 given the security nightmares; oftentimes they have to because some custom line of business app written in 2001 is now cruical and impossible to rewrite to work with modern systems.


问:
Steps required to start programming in C++ to develop native applications
I am dealing around with C# .Net for almost around a year now. I got lots of experience (I owe most of it to guys at stackoverflow).

Now I am thinking to start working with C++ as well. Mainly because I would like to be able write codes resulting in applications that are not .Net dependent so they can be executed in most of environments also having cross-platform in mind. Although I have to confess, writing code in .Net with C# and Visual Studio can not be easier nowadays.

Of my other reasons I can name, since I am studying electrical engineering, who knows maybe I later need to write drivers for hardwares!

My questions are:
1- Am I right with the idea of learning C++ I mean is it add to my value if say I am going to work as a developer later?
2- What tools will I need to start programming in native C++ that is perhaps compilers and IDE

答: Learning something new is always positive, but some things might be more useful to learn than others.  Since you suspect you may be working on device drivers in the future then getting under the hood is exactly what you should be doing.  For the most part, just learn what interests you.</p>


答:
This announcement really doesn't change how you should approach browser support. It will merely make upgrades from IE8 on move much faster. Anybody else who is on IE7 or below is there deliberately and this update will force few, if any, upgrades.

That said...

Just stop supporting IE6. In my experience, base on web stats and my work even in coporate is that IE6 is effectively a non-factor at this point. So many MAJOR websites (Amazon, Facebook, etc...) have stopped supporting it, there is no reason for you to support it either.

Analyze traffic for your users, see what they are currently using. Make a determination if you can stop supporting an older version of IE. Chances are you will still need to support IE7, though, I suspect not for long as I believe Facebook is dropping support...others will start following soon. However, you alone can make that determination, based on your traffic stats and your average expected clients.

Title: How quickly is the silent IE upgrade likely to propagate to end users? What about managed corporate IT infrastructures?

Body:
According to this article from the BBC and this post on Microsoft's Exploring IE Blog, Microsoft has planned to automatically upgrade Windows XP, Windows Vista, and Windows 7's IE to the latest version.

Microsoft has stated that they will also allow people to opt-out of this update through the use of the The Internet Explorer 8 and Internet Explorer 9 Automatic Update Blocker toolkits and will respect any previous declined automatic updates. I assume managed corporate IE managers can also block whatever they want.

Microsoft's blog post states that the release will begin in Australia and Brazil to be "scaled up as time goes on."

I'm wondering, from the perspective of a web designer, how rapidly these upgrades are likely to be propagated to average end users, but also especially those in tightly-regulated corporate IT infrastructures. Given best (or common ;) practices in the corporate world, as well as average end-user behaviour, how soon can I stop investing a significant amount of time in backwards-compatibility with IE6 and 7?


问:
Make a big deal out of == true?
There is a colleague of mine who constantly writes:

```<code>if (someBool == true)
</code>```

It drives me up the wall!  Should I make a big deal of it or just drop it?

答: It's a code smell for a novice developer. They have yet to master/internalize the boolean condition and must explicitly evaluate to the true or false condition.</p>

Title: Make a big deal out of == true?


问:
How can I design a model layer without ORM, and when should I use it?
I'm a PHP developer who started with CodeIgniter. In it, designing models was easy: it seemed like each method defined in models was the equivalent of static methods in a normal, objected-oriented environment.

I tried FuelPHP, which has an built-in active record style ORM, and PHP ActiveRecord to use with CodeIgniter. I found creating models was easy with ORM, and taught me best practices when designing models.

However, I didn't like that I was tied to a specific ORM implementation, and as I got better with SQL, I thought ORMs were a bit heavy when compared to how quickly I could retrieve stuff with SQL.

But when I try to design models from scratch without ORM, I'm lost: The ORM  system of one class per table and queries with eager loading makes sense, and seems like worth the performance hit for using ORM.

In what situations should I avoid using ORM? How can I design models without using ORM, so that I can use SQL directly?

答:
I didn't like the fact that i was tied to a specific ORM implementation...

Why not?  Are you afraid you will pick the wrong one?  That sounds like a case of "Not Invented Here."  You are going to be dependent on the chosen language, and SQL, and the web framework, and a dozen other things.  An ORM is just one more.

As long as the performance through an ORM is adequate, I would use it.  If the ORM-generated queries are too slow for some pages, then create a SQL view or stored procedure to retrieve precisely the needed information, and map the results to a custom presentation class.  Use the ORM for the mapping if it is convenient, otherwise you can map the SQL result set to an array of objects yourself.


问:
Is documentation a User Story?
We need to do some user documentation for a product we have been working on for the past few sprints. We are now starting a new project in the next sprint and the PO is making the documentation for the product produced previously a User story for this sprint.

I am just wondering your opinion on this approach. Personally, I don't agree that documentation is a User Story within Scrum because it doesn't produce any code.

EDIT: Thanks for your opinions guys. I had it in the back of my head that a sprint was to implement an increment of working software, but your views have changed my outlook. Thank you for all your answers.

答:
Ideally, documentation is part of every user story and never builds up. But, in the real world, that often doesn't happen. In that case, you should create a user story for catching up on a specific missing piece of documentation.

You're right, it doesn't produce any code. But it does satisfy a user requirement and should be prioritised against other user requirements.

If this means that it never gets done, because this and that functionality is being worked on then you probably didn't need the documentation that badly.

Title: Is documentation a User Story?


答:
"As a user of X, I need to know how X works" seems like a legitimate user story to me.  This could result in written documentation or online help.

The point isn't just code--it's meeting the users' requirements.

Title: Is documentation a User Story?

Body:
We need to do some user documentation for a product we have been working on for the past few sprints. We are now starting a new project in the next sprint and the PO is making the documentation for the product produced previously a User story for this sprint.

I am just wondering your opinion on this approach. Personally, I don't agree that documentation is a User Story within Scrum because it doesn't produce any code.

EDIT: Thanks for your opinions guys. I had it in the back of my head that a sprint was to implement an increment of working software, but your views have changed my outlook. Thank you for all your answers.


答:
In JavaScript, I prefer if(bool) when I have sufficient documentation explaining what the method expects... but when evaluation of true can mean the variable exists, equals the number 1 or the boolean true, it's tougher.

Strongly typing in JS also means less flexibility.  Tough call.  Strongly typed languages, lay down the hammer.  Otherwise, ask why he does it?

Actually, there's your answer: ask him why.  Then correct him.

Title: Make a big deal out of == true?

Body:
There is a colleague of mine who constantly writes:

```<code>if (someBool == true)
</code>```

It drives me up the wall!  Should I make a big deal of it or just drop it?

OwnerDisplayName: Clint


答:
I agree with pdr's documentation assessment if its about requirement, technical or project documentation.  Ideally it should be incorporated into sprint work.

Product documentation I feel is very different as it is an actual user requested deliverable and directly provides value to the user.  This should be understood of course that Product Documentation is essentially not a Technical Task but a Functional Task, and may or may not be a suitable activity for a technical resource on the project.

I think it should be a user story, however I feel that a project resource that has a firm understanding of the business requirements, user perspective and good technical writing skills should be assigned these tasks.  Ideally this would be a business analyst if one is available, or perhaps a higher order QA tester with a firm understanding of the requirements, user stories and good technical writing skills.  This could also be a developer, however product documentation written by developers tends not to be as high quality or as useful because developers usually are too close to the technical details.

Title: Is documentation a User Story?


问:
How to prove an application is built on a bad codebase?
I'm currently reviewing a system built by some developers that previously worked at my job. The system works pretty well from a user's point of view, but when delving into code review it's a utter mess. I'm more than convinced that the way the application is built won't hold up for future updates, let alone high increases in usage.

The problem is that I know how bad it is, but my superiors don't. How can I prove it to my manager so he actually sees the problem and can be convinced to do minimal triage on the current codebase, and in the near future start a new line of development for the next version of the application?

答:
When you talk about proving something, all that scientific method stuff comes into play, and part of what that means is that if you are going to accept objective standards of deciding what's true, you must accept the possibility that, upon investigation, those annoying facts turn out not to be on your side.

In your case, I think there are 2 things to be proved.

First, that the current codebase is "bad".  What you probably can prove is that "the professional opinion of nearly all developers that examine this code is that it's bad".

Second, that the company would be better off rewriting the codebase.  This is a problem because even if the first point is true, the second might not be.  Also, you don't know enough to make this determination.  This is management's job, and if you want them to respect your professional judgement about the first point, you should respect theirs about the second.

But they can't make the determination about the second point without information you provide.  You need to communicate what you know about how the problems in the code will impact the business, and what you know about how a rewrite would impact the business.  This is difficult, since both involve predicting a future that has a lot of uncertainty.

But you can try to state the problem in business terms.  How much extra time is spent on changes and regressions?  What would a rewrite cost?  How quickly will the costs of the current system go up over time if not rewritten?  What if there is an increase in usage, what's the chance of a disaster if the current code is kept?  You can't really know any of this, but you can give a better guess than anyone else.  Give a range, or something to communicate how accurately you think you can predict these things.

Most developers do not like maintaining lousy code.  Which is why it can be unfortunate that code that is a no-brainer to rewrite from a developer perspective may not be worth rewriting from a business perspective.

For example, even if the rewrite ends up profitable, it might be worth less than the opportunity cost of spending the money elsewhere in the company.  Or the bad codebase might take longer to change and have more regressions, but not enough to make a rewrite profitable.  They may be looking to get bought out in the next few months, and spending money on a rewrite will show up on the books but buggy software won't.

Try to think about it from the business perspective, and don't cook the numbers to get what you want.  A big rewrite is almost never a no-brainer from a business point of view.  If you want to prove something not directly provable, try your best to disprove it.  If you keep trying your best to come up with a way not to rewrite from scratch but nothing you come up with makes sense, maybe then it's really time to rewrite from scratch.  And making that effort will show your management that you are serious about representing the company's interests, not your own (you are representing the company's interest, not your own, right?).


答:
Pick an example that is easy to understand where managment would think it is a simple change request, but because of the existing design it is much more difficult.

You don't want them to dwell on the specific request, but make sure you let them know that this is what ANY request for change is going to be like. Nobody wants to be painted in a corner with an application. Developers believe in YAGNI, but management believes in CYA.

The suggestions for load testing could be a good approach, but they may not be convinced the increased usage concerns meets any real world growth potential (The company is not going to double in one year.).

Everything is relative. They may not want to put the resources into this project when they have plans for more important projects to spend your time on. Don't get labeled as not seeing the big picture.

Title: How to prove an application is built on a bad codebase?

Body:
I'm currently reviewing a system built by some developers that previously worked at my job. The system works pretty well from a user's point of view, but when delving into code review it's a utter mess. I'm more than convinced that the way the application is built won't hold up for future updates, let alone high increases in usage.

The problem is that I know how bad it is, but my superiors don't. How can I prove it to my manager so he actually sees the problem and can be convinced to do minimal triage on the current codebase, and in the near future start a new line of development for the next version of the application?


问:
JSP, EL, JSTL: learning from a web designer perpective
I have two books geared toward learning JSP. From what I've read, one motivating feature/benefit is that it is easier for web designers (they apparently don't, as a rule, know Java) to work with dynamic pages via EL/JSTL.

From what I've seen so far, learning EL/JSTL requires a basic understanding of Java. I have yet to see an example that doesn't have a Java class to reference. Since that is what I've seen, I wonder if someone can tell me that this is true or not.

To make the question clear: Do web designers have to get a grasp, on a very basic level, of how a Java class works (e.g. fields, setters, getters, args, constructors...)?

This question is really meant to help me decide whether or not to ask another question; it is a qualifier.

答:
Technically, you can create a very substantial set of custom tag libraries that cover everything you want to do that would need to deal with classes and other Java artifacts without those libraries.

In practice, however, such comprehensive taglibs are rarely created and maintained.

Thankfully, only a basic understanding of Java is needed to do most things that a non-programmer would need to get at when dealing with the page layout in the JSP.

So, while the promise that a designer doesn't need to know Java can be held to, the reality is that they will need to be able to understand how to use some basic Java to do things. In my experience, this is well within the abilities of most designers.

OwnerDisplayName: yas

OwnerDisplayName: cdeszaq


答:
In my experience, JSPs are not developed by web designers, but by the Java developers who also developed the Java classes which constitute the presentation layer of the application.

Those are rarely very good at web design, but most of the pages of an application follow the same design principles, and once a web designer has designed one or a few static pages with the appropriate markup and CSS styles, the developer can reuse this template and make his own dynamic pages without the help of a web designer.

Title: JSP, EL, JSTL: learning from a web designer perpective

Body:
I have two books geared toward learning JSP. From what I've read, one motivating feature/benefit is that it is easier for web designers (they apparently don't, as a rule, know Java) to work with dynamic pages via EL/JSTL.

From what I've seen so far, learning EL/JSTL requires a basic understanding of Java. I have yet to see an example that doesn't have a Java class to reference. Since that is what I've seen, I wonder if someone can tell me that this is true or not.

To make the question clear: Do web designers have to get a grasp, on a very basic level, of how a Java class works (e.g. fields, setters, getters, args, constructors...)?

This question is really meant to help me decide whether or not to ask another question; it is a qualifier.

OwnerDisplayName: JB Nizet


问:
What are your initial three steps when you are first presented with a software problem?
I am curious about the very early steps that a programmer's mind takes when it first encounters a problem that it is supposed to solve. How do you start reasoning about it ? What are the first questions you ask yourself ??.

Ok, let me make it more concrete for those of you who think the question is too vague or entirely situation dependent. Pick any of the following   requirements and think out loud about your very first hunches/impressions/tendencies about how to solve it.

1) build a simple word processor with about as much functionality as MS Word Pad

 2) design a single person card game (e.g. Solitaire)

 3) build a scientific calculator

 4) Any  problem of your choosing with similar scale/complexity as the above three

答:
My first question is always "What is the business need/problem we are trying to solve?".  Too many times, I have been asked to build a solution that ends up not actually addressing the customers problem.

If I can understand their needs and goals, I can make sure that what I am building will be useful to them. This also helps reduce misinterpretation of requirements and reduces the number of iterations needed to get something usable into production.

OwnerDisplayName: mumtaz

LastEditorDisplayName: mumtaz


问:
How do you validate critical input that cannot be vetted?
How does one prevent users from creating erroneous input sets, when there is no practical way to vet the input?

The scene

I modify a small ERP package written in Visual FoxPro.  One part of the package concerns itself with printing truck manifests and invoices to be sent with the drivers on their delivery routes.  The print routine, when fed nothing as an input, will attempt to print everything, resulting in reams and reams of printer paper being wasted on a high-speed printer.

I am not in a position to re-write any of the GUI interface elements, nor can I adapt any frameworks, tool kits, or other outside code to be used in this situation.  The reasons are related to office politics, please do not suggest that I can override the existing ERP framework, as it is not an option for me.

The issue

The users are in a high-pressure, time-critical environment. Each process is measured in minutes or even seconds, which means that I have to minimize processing time as much as possible.  Because of this environment, and possible distractions, users frequently ignore the dialogs, pressing the [Enter] key which causes the focus to rapidly move through the form and eventually landing on the action button for the input dialog, resulting in them triggering an automatic printout.

The input consists of a date range, route range, and sales order range.

The input for date range cannot be auto-set to "today's date", as frequent back-printing is required.  Also, the end-users work during midnight, i.e. date rollover makes this impractical without rigging a routine that auto-detects the change, etc.

The input for routes cannot be hard-coded, nor can it be deduced from routes that have already been shipped, because re-prints are required (see above).

The input for sales orders only has meaning when printing single orders or specific ranges.

So, frankly, there is no practical way to validate input.

The action button that triggers printing cannot be blocked.  Any suggestions that a blocking dialog be placed in front of the user will be ignored.  I am not at liberty to discuss why this is not an option, other than the concept has been already discussed elsewhere on the site (from a different vantage point) and was rejected.

Blocking printouts when all inputs are empty was rejected as a design decision as the software must accommodate this as a feature.

The users

The users have been repeatedly asked not to do this.  They frequently ignore this advice.  Triggering this unfortunate event is not something that their foremen/managers will address, so there is no pressure to end the behavior.

The organization

I do not have a say in the workflow involved, only the modification of existing software components affected by that workflow.

The vendor

The vendor second-sources the package as a custom installation from the original software vendor.  The vendor requires that all code changes be sent back to them for integration into their codebase.  Significant changes to architecture will result in increased future costs during version migrations due to the extensive customization involved; in some cases, the programmers have even told me that they will completely ignore such large changes and will do as they please.

The software

I have no say in the selection or installation of the software, so changing the platform is out of the question.

Regarding the environment of the software, each invoice printed is a single call.  There isn't a batch printing facility, and because of how the print facility is integrated into the system (and some language quirks as well) it isn't feasible to make a batch wrapper around that API.  Topping this off, this part of the program calls another program that does the invoice print, which in turn calls the print-a-report API, which prints a single invoice.  Horrid design, I know.

Input forms are a weird combination of a form header that is devoid of input boxes, but can contain other GUI elements.  Input boxes are defined at runtime.

The objective

The software will prevent the users from erroneously printing all paperwork.

How would you solve this issue?

答:
How would you solve this issue?

Clearly separate the use cases.  There's a "print something right now" case that can lead to endless output.  Fix this to provide all the right defaults.

There's a "reprint some previous thing" case that is a special (non-standard) request where inputs can be checked carefully.

The input for date range cannot be auto-set to "today's date", as frequent back-printing is required.

False.

The input can be auto-set today with no effect at all on frequent back-printing requests.

What possible impact would a auto-set to "today's date" have on back-printing requests?  Please enumerate them in the question.

The input for routes cannot be hard-coded, nor can it be deduced from routes that have already been shipped, because re-prints are required (see above).

False.

Reprints and back-prints are a special case.  They never have default fields and are the exception, not the rule.


问:
Never written much unit tests, how can I practice more of it?
I have an interview coming up soon next week and there's a few things on their list of responsibilties for this software development job (the job position title is vague, it says java developer) that I am worried about:

Unit test features

Debug new features

Provide recommendation on test case design (what is this?)

I am worried because in my past software projects, I have not bothered writing unit tests. I know how to use JUnit to write tests in Eclipse and the process but it's just that I have not much experience writing tests. For example, I rely on data from the web, which varies a lot from each other, and process this data. How can I write test cases for every single type of data? Also, if the data is from a local database, how would I write a test case that checks that data from tables are being read properly?

I've used the debug feature in Eclipse whenever I could, but sometimes, when I am accessing a library which doesn't come ith source code for (e.g. commercial 3rd party Jars), the step into feature would stop. So for most cases, I just System.out.println to discover where the bug is happening. Is there a better method?

How can I practice in the short period of time to be somewhat competent in writing unit test?

答:
Create a simple class and write unit tests for it. Only through practice will you be able to understand how it is done. If necessary, find examples of unit tests in open source projects or refer to some online tutorials for guidance.

Good luck on your interview!


答: Can you determine before printing how many pages will be printed, or in some other way measure the size of the output? If so, determine a maximum size for normal use, and if it is bigger, use a confirm dialog that states the output size and, so it cannot be dismissed without reading, requires the user to type back the output size to confirm.</p>

Title: How do you validate critical input that cannot be vetted?

Body:
How does one prevent users from creating erroneous input sets, when there is no practical way to vet the input?

The scene

I modify a small ERP package written in Visual FoxPro.  One part of the package concerns itself with printing truck manifests and invoices to be sent with the drivers on their delivery routes.  The print routine, when fed nothing as an input, will attempt to print everything, resulting in reams and reams of printer paper being wasted on a high-speed printer.

I am not in a position to re-write any of the GUI interface elements, nor can I adapt any frameworks, tool kits, or other outside code to be used in this situation.  The reasons are related to office politics, please do not suggest that I can override the existing ERP framework, as it is not an option for me.

The issue

The users are in a high-pressure, time-critical environment. Each process is measured in minutes or even seconds, which means that I have to minimize processing time as much as possible.  Because of this environment, and possible distractions, users frequently ignore the dialogs, pressing the [Enter] key which causes the focus to rapidly move through the form and eventually landing on the action button for the input dialog, resulting in them triggering an automatic printout.

The input consists of a date range, route range, and sales order range.

The input for date range cannot be auto-set to "today's date", as frequent back-printing is required.  Also, the end-users work during midnight, i.e. date rollover makes this impractical without rigging a routine that auto-detects the change, etc.

The input for routes cannot be hard-coded, nor can it be deduced from routes that have already been shipped, because re-prints are required (see above).

The input for sales orders only has meaning when printing single orders or specific ranges.

So, frankly, there is no practical way to validate input.

The action button that triggers printing cannot be blocked.  Any suggestions that a blocking dialog be placed in front of the user will be ignored.  I am not at liberty to discuss why this is not an option, other than the concept has been already discussed elsewhere on the site (from a different vantage point) and was rejected.

Blocking printouts when all inputs are empty was rejected as a design decision as the software must accommodate this as a feature.

The users

The users have been repeatedly asked not to do this.  They frequently ignore this advice.  Triggering this unfortunate event is not something that their foremen/managers will address, so there is no pressure to end the behavior.

The organization

I do not have a say in the workflow involved, only the modification of existing software components affected by that workflow.

The vendor

The vendor second-sources the package as a custom installation from the original software vendor.  The vendor requires that all code changes be sent back to them for integration into their codebase.  Significant changes to architecture will result in increased future costs during version migrations due to the extensive customization involved; in some cases, the programmers have even told me that they will completely ignore such large changes and will do as they please.

The software

I have no say in the selection or installation of the software, so changing the platform is out of the question.

Regarding the environment of the software, each invoice printed is a single call.  There isn't a batch printing facility, and because of how the print facility is integrated into the system (and some language quirks as well) it isn't feasible to make a batch wrapper around that API.  Topping this off, this part of the program calls another program that does the invoice print, which in turn calls the print-a-report API, which prints a single invoice.  Horrid design, I know.

Input forms are a weird combination of a form header that is devoid of input boxes, but can contain other GUI elements.  Input boxes are defined at runtime.

The objective

The software will prevent the users from erroneously printing all paperwork.

How would you solve this issue?


答:
I Guess it depends what is bad about the code base.  Being "Not the way I would do things" does not mean it is a bad code base.

Things that actually make a bad code-base:

Security holes

Problems that leave the Server, application, and/or data vulnerable. Especially anything that leave sensitive company, client or customer data at risk. These should be easy to document.

Working Broken

It is only working because you massage the data and perform maintenance on the application nearly continuously to keep it working.  If you were to leave and no one took up the slack it would not longer be working. - Document how much time you are spending doing this. And note how much you could save.  Quite often these processes are inefficient for users as well and you may be able to document that as well.

Does not actually work

It appears to work but the results are incorrect.  This generally causes problems down the line like numbers not matching, high defect rate, etc.

What is not bad codebase (just not good):

Written on obsolete unsupported tech.  (VB6, COBOL, .net1.1 Etc.)

Note the advantages of migrating to a new technology.  Try to find a migration path that moves pieces at a time so that you can minimize risk and build user and management confidence. Make sure that the logic works basically the same as the original.

Undocumented/poorly formatted code

This is the easiest for you to fix because generally you can add comments and correct the formatting with out actually impacting the code.  But it does not require a rewrite.  If you feel this is combined with other issues the first thing to do is fix this so you can better assess the viability of the code.


答:
The only way to practice is to just do it. I'm still learning how to write effective unit tests myself.  Unfortunately, you need hours behind the wheel to get true feeling for what good unit tests looks like.  The only shortcut I could think of is working 16 hours a day instead of 8 and you'll learn twice as fast, but only until fatigue sets in.

Few things I'd suggest:

Make sure you are working on a task that is not time critical. Time pressures and the feeling that you must be done right away, is what typically causes people to take short cuts and either a) not produce any tests, b) produce very little or c) produce tests which are very hard to maintain because you never took the time to refactor them.

Approach the task of writing unit tests with the same requirements for code quality (if not more strict) as you would production code.  Some people think that unit tests are not being released, so it's not as important to follow good practices and then they end up with tests which are very fragile and extremely hard to maintain.

Allocate enough time to not only write the test but also any helper classes that would make yours (and others on your team) life easier.  From my own experience, it seems that people tend to take shortcuts when writing tests because certain tasks are too long to code properly and because it takes even longer to factor code out into a library, they end up copy/pasting code between unit test projects. I started a unit test helper library for our group with the intention that it would speed up development of future tests (some common functionality in the library: simple code for recording/verifying mock object actions, code for working with files to help unit tests which need to feed external data, standard hooks to override win32 calls...).

Get into a habit of practicing TDD where you write tests before the code. At first it seems like unit tests are a lot of overhead, but since you must exercise the production code you've just written anyway, TDD more than makes up for it because it becomes incredibly easy to verify functionality of the production code so even when not considering all the long-term benefits, it will immediately start paying back the time it took you to write the tests.

This outlines how to learn to write good unit tests.  If you want to simply "know" what a good unit test is, there's a number of really good books out there.  (I'd start with The Art of Unit Testing)

Title: Never written much unit tests, how can I practice more of it?

Body:
I have an interview coming up soon next week and there's a few things on their list of responsibilties for this software development job (the job position title is vague, it says java developer) that I am worried about:

Unit test features

Debug new features

Provide recommendation on test case design (what is this?)

I am worried because in my past software projects, I have not bothered writing unit tests. I know how to use JUnit to write tests in Eclipse and the process but it's just that I have not much experience writing tests. For example, I rely on data from the web, which varies a lot from each other, and process this data. How can I write test cases for every single type of data? Also, if the data is from a local database, how would I write a test case that checks that data from tables are being read properly?

I've used the debug feature in Eclipse whenever I could, but sometimes, when I am accessing a library which doesn't come ith source code for (e.g. commercial 3rd party Jars), the step into feature would stop. So for most cases, I just System.out.println to discover where the bug is happening. Is there a better method?

How can I practice in the short period of time to be somewhat competent in writing unit test?


答:
It sounds to me like you've got a requirement to fix something, but every time you propose a solution (and there are plenty of good ideas in your list) it gets shot down.

This is the point where you need to push back.  You don't need a vague idea that "this is wrong; fix it."  What you need is a spec.  Ask the people who want it fixed exactly what they do want done, since so far all you have is what they don't want.  That much is easy: just do nothing, and then you won't do any of the things they don't want.  Tell them that if they want changes made, they need to come up with positive, concrete rules and you will implement them.


答:
You have a situation where the current process default is creating waste and costing time for your users.

Disable the ability to just hit enter all the way though by having the focus on the "reset parameters" button(create one if needed) so if they hit enter it stays on that screen, but does nothing.  I would create some sort of hot buttons for the most common selections to auto fill the form with those parameters to help the users out. But this should solve your problem even with out the hot buttons.


问:
interview for an internship but I think I may be unprepared
I have an interview for a C++ internship position.  Now, the thing is I've taken two out of three quarters of the basic CS classes (in C++) at my community college and we covered the basics up to arrays, pointers, linked lists, recursion, etc (basically all of Walter Savitch's Absolute C++ book).

I spoke to the interviewer on the phone and he said the interview will include technical questions on trees, hashes, probably some sorting algorithms, and other stuff like that.  I have less than a week to prep for the interview.

What can I do to familiarize myself with the absolute, bare, essentials of the aforementioned interview question topics?

Or, is it just a waste of time for me until I take the next class that covers all of those things?

答:
You could try to get the material for the class about algorithms and data structures. There is a lot of theory behind those things, but I don't think they'll ask you in depth about that for an internship, so you don't have to really get behind the material, but it helps to have read at least the introductions for popular algorithms and to know what they do.

You probably should know how Bubble Sort, Merge Sort and Quick Sort work (they're a popular selection of sorting algorithms, though there are many more). Maybe the Wikipedia articles on those are sufficient to get the algorithm. You should also implement them. It's not that difficult, and it will greatly help you to understand the algorithms.
Same thing with trees and Hashmaps/Hashtables, try to understand the concepts and implement them. Linked Lists belong in that category as well as a typical data structure.
Graph algorithms are interesting as well and would most likely be covered in the material for the corresponding graph, but sorting and data structures probably takes precedence.

The interview itself is not going to be a waste of time. It's going to give you experience, no matter how it works out. And unless you abuse the interviewer or something like that, a failure will most likely also not burn bridges at the company - you're a student and improving, so you can always reapply under the premise that you have worked hard and are much better equipped then.


答:
How about

```<code>if (x == "true")
</code>```

WHY IS THAT A STRING?!

Title: Make a big deal out of == true?

Body:
How about

if (x == "true")

WHY IS THAT A STRING?!


答:
This is easy, if they leave everything blank you prompt that this will print everything, however, the DEFAULT selection in that prompt MUST be to cancel.

If they enter values, print whatever they asked for.

This way, they won't accidentally blaze through the form and print everything.  They'll blaze through and print nothing.  They would need to pause, and print change the selection at the prompt to OK, from Cancel, to print everything.


答:
Allow me to restate the problem.

Present state:  blindly pressing Enter causes reams of paper to be printed.

Desired state:  blindly pressing Enter does not cause reams of paper to be printed.

Solution:  change the software so that blindly pressing Enter does something, anything, other than causing reams of paper to be printed.

That pretty much leaves you with the problem of what it should do instead.  Personally, I would ask the operators what they want.  My guess is something like printing the most urgent invoices that haven't already been printed.  Leave the ability to print all, but require a conscious decision to do so.


答:
basics up to arrays, pointers,

Arrays and pointers are not the basics of C++. std::vector<T> and std::string is the basics of C++. If you don't know and use the C++ Standard Library extensively and as an exclusive replacement of C arrays, and mostly raw pointers too, (except in some very niche cases) then you don't qualify as a basic C++ user. And if you find yourself dealing with T[]  or array-to-pointer decay, then you've done it wrong in all scenarios.

Title: interview for an internship but I think I may be unprepared

Body:
I have an interview for a C++ internship position.  Now, the thing is I've taken two out of three quarters of the basic CS classes (in C++) at my community college and we covered the basics up to arrays, pointers, linked lists, recursion, etc (basically all of Walter Savitch's Absolute C++ book).

I spoke to the interviewer on the phone and he said the interview will include technical questions on trees, hashes, probably some sorting algorithms, and other stuff like that.  I have less than a week to prep for the interview.

What can I do to familiarize myself with the absolute, bare, essentials of the aforementioned interview question topics?

Or, is it just a waste of time for me until I take the next class that covers all of those things?


答:
Some warnings to avoid some common "detours":

1) C++ and C# looks very similar, but their similitude ends just there (in the look).

2) "Native application" -on both Windows and Linux- are not C++, but C since C is the native language for both the OS kernel API. In this sense, all C++ libraries interfacing the OS are just one level of abstraction away

3) C# libraries (.Net in particular) is strongly based on an OOP hierarchy. In C++, OOP is just one of the possible programing paradign, and not always the most efficient, but ...

4) C++ had a long standardization process that lasted decades. During this process it changed a lot either as a language and as the standard library. Unfortunately many frameworks and libraries developed to support OS native interface where written decades ago, and still have long no-more standard backlog. As far of today, there is just no C++11 GUI library that is really inspired by C++11 itself, rather than making pre-C++11 code compilable in C++11.

5) As a result, learnig the "state of art" C++ will make you fine and efficient in deploying your own algorithms and classes, but drops you back to C wherever you need to interact with the native API or ...

6) Learning one of the existing C++ framework that abstract the GUI concept (Like MFC) sometime even on multiple platform (Like GTK, WxWidget etc.), will not make you a "good C++ programmer" since that will bring you back to C++03 or even C++98.

All that said, you have two paths:

a) Learn a framework and through that learn C++ (or ... that part of C++ used to sustain the framework itself). This will make you fast productive, but less efficient in code structuring and proper reuse. (you use "past techniques", and "framework specific tips & tricks")

b) Learn C++ for what it is (start with book that teach C++ together with its library: avoid all books that talk about pointers and array before vectors and containers), and once you understood the proper practice, develop yourself the API wrappers (is not that difficult) to sustain your own apps, but be ready to replace  them as soon as new framework will come for C++11 GUI system.

Title: Steps required to start programming in C++ to develop native applications

Body:
I am dealing around with C# .Net for almost around a year now. I got lots of experience (I owe most of it to guys at stackoverflow).

Now I am thinking to start working with C++ as well. Mainly because I would like to be able write codes resulting in applications that are not .Net dependent so they can be executed in most of environments also having cross-platform in mind. Although I have to confess, writing code in .Net with C# and Visual Studio can not be easier nowadays.

Of my other reasons I can name, since I am studying electrical engineering, who knows maybe I later need to write drivers for hardwares!

My questions are:
1- Am I right with the idea of learning C++ I mean is it add to my value if say I am going to work as a developer later?
2- What tools will I need to start programming in native C++ that is perhaps compilers and IDE


答:
However much you learn during the next week, make sure to be honest to your interviewer. Since it's an internship for a student, they won't be too harsh. If you can't answer a question he is asking about stuff you didn't study yet, tell him so. But be prepared to also tell him what you do know and what you are good at. </p>

<p>Apart from that, I also think that it will be a good experience for you regardless of the outcome. The worst that can happen to you is that they don't accept you. Then you'll at least know what to expect at your next interview. </p>

Body:
However much you learn during the next week, make sure to be honest to your interviewer. Since it's an internship for a student, they won't be too harsh. If you can't answer a question he is asking about stuff you didn't study yet, tell him so. But be prepared to also tell him what you do know and what you are good at.

Apart from that, I also think that it will be a good experience for you regardless of the outcome. The worst that can happen to you is that they don't accept you. Then you'll at least know what to expect at your next interview.


答:
I'll try to give an answer for a more generic question: how to avoid a user making a mistake which leads to disaster or something which cannot be canceled or undone (like wasting paper by printing several pages the user didn't expect to be printed).

As said in the original question:

The users are in a high-pressure, time-critical environment. Each process is measured in minutes or even seconds, which means that I have to minimize processing time as much as possible.

This means that:

The software product must make its best to increase the productivity of the employees. When every second counts, user experience and productivity is even more important than for general products, where a loss of a few seconds on some feature the person don't even use too often is acceptable.

The users are too busy to pay attention to the software product. When, in a calm environment, I use some feature of Microsoft Word I used the last time a year ago, if Microsoft Word asks me a question, explaining what would be the consequences of my choice, I can afford spending a minute or two reading the question, and maybe even going to read the documentation. In your case, you can't afford that. Your users don't have time to read.

Message boxes: no, no and... no!

As already explained in my other answer, message boxes are evil in most cases, for two reasons (see About Face 3 by Alan Cooper for more details):

The dialog that cried “Wolf!” principle incite the user to dismiss repeatedly a dialog without paying attention if the application shows the same dialog too often.

The dialog disturbs the workflow: the user can't stay focused on the application, because the dialog grabs this focus away and the interaction with the application is suspended until the dialog is dismissed¹.

This means that dialog boxes are an absolute evil in your case from the UX point of view: they will be dismissed and they will decrease productivity in an environment where every second counts.

Other means

According to the question:

"The input consists of a date range, route range, and sales order range."

There are no wrong values (for example the user can enter a previous date, a future date or today in the first field), so validation is not possible.

"The print routine, when fed nothing as an input, will attempt to print everything, resulting in reams and reams of printer paper being wasted on a high-speed printer."

It's totally possible to ask to print with default data used.

In more generic terms, it means that:

You have a default value, which can actually be valid,

You don't want the users to hit "Print" button with default values kept by mistake, while they intended to change them.

Here's a few techniques you can try:

1. The magic undo

Yes, the users are in a time-critical environment. Yes, once the printer starts printing, it cannot be stopped. But there is still something you can do.

Even in a time-critical environment, chances are that printing right now and printing in five seconds will not change anything.

When the user clicks "Print", display a small "Undo" button, just like GMail does when you ask to remove, by mistake, all your mail. Wait for five seconds². Hide the "Undo" and only after that, print.

Now, the user has a chance to notice the mistake and cancel it before the harm is actually done, while the stuff is printed only with a small five seconds delay.

2. The discrete "default value" background

Is having default values suspicious?³ With one value, it's rarely suspicious. With three, there are chances that the cases when the user has to keep all three values by default are quite rare.

In this case, you can:

Highlight the value when it has its default value. Not in red: red is for invalid values. Set it to yellow-orange, and back to white when the user alters the default value.

Or disable the "Print" button until a value is changed. Add a checkbox nearby, which the user can check to confirm that his intent is to print with default values.

3. Enhance the UI of your controls

We are Friday, 6th of January 2012 today. What will be the date the next Thursday? Quick, quick, you're under pressure, you have only one second for your answer. Also, you're tired and there is a lot of noise all around. Not easy to answer, isn't it?

People can't manipulate dates easily when it's written as 1/8/1012. Saturday, 7th of January (tomorrow) is a bit easier. A graphical view which highlights Saturday and Sunday, shows today and the offset is even better.

Nothing is as ugly as "Location: NYC". Those three letters are meaningless when you're tired and work in a stressful environment; mistakes are easy. Instead, a graphical map of United States showing a red dot for New York city is much more appealing, and the user has much more chances to notice that, while he wanted to select San Francisco, the red dot seems to appear in a wrong place.

Would you enjoy if your GPS told you that you have to move from 38.90403, -77.04878 to 38.90568, -77.04665, then turn right and move to 38.90565, -77.04345, then turn 90° left and move to 38.90660, -77.04345? Would you be able to concentrate on your work (the road)? Showing 1/8/2012 and NYC to busy users is as friendly as a GPS that throws raw coordinates instead of a 3D view of a map full of color.

By providing richer controls and richer visualization of data, you can decrease the level of mistakes of your users in a stressful environment.

¹ This, by the way, applies to other variants of dialog boxes. You previously asked a question about the dialog boxes where the buttons will be random and which will make it difficult to dismiss. Sadly, such approach will not help, but only hurt: the users will still dismiss what is said by the dialog, but waste more time trying to close it to return back to work.

² I say five seconds as an example. You have to monitor the activity of the users for a few months to see how fast they click on "Undo". Chances are it will be below one second. If you see that the delay is from 0.6 to 1.8 s. with an average of 1.1 s., you can show the "Undo" for two seconds, and then print.

³ Please, please, please, say no! Because if it is, it means that there is something wrong with your default values. For example if the default value for the date is today, while in 75% of cases, the users have to set it to tomorrow, in 10% to yesterday, and in 10% to the day after tomorrow, you should rather set the default value to tomorrow.


问:
Is Learning C++ Through The Qt Framework Really Learning C++
The problem I have, is that most of the C++ books I read spend almost forever on syntax and the basics of the language, e.g. for and loops while, arrays, lists, pointers, etc.

But they never seem to build anything that is simple enough to use for learning, yet practical enough to get you to understand the philosophy and power of the language.

Then I stumbled upon QT which is an amazing library!

But working through the demos they have, it seems like I am now in the reverse dilemma. I feel like the rich man's son driving round in a sports car subsidized by the father. Like I could build fantastic software, but have no clue what's going on under the hood.

As an example of my dilemma take the task of building a simple web browser. In pure C++, I wouldn't even know where to start, yet with the Qt library it can be done within a few lines on code.

I am not complaining about this. I am just wondering how to fill the knowledge void between the basic structure of the language and the high level interface that the Qt framework provides?

答:
Is Learning C++ Through The Qt Framework Really Learning C++

Maybe.

I'd have to see the code you're putting in your event handlers.

Really though, don't be obsessed with how much you "know".  We all use windowing frameworks and  we're all still learning.  Just keep coding/reading new things and you'll continue learning C++.  Learning a new windowing framework is a great addition to your skills even if it might not mean you can implement a neural network or a quicksort in C++.


问:
What is a good overview of options for access controls/permissions?
I'm in the process of designing the access control portion of a moderately complex application, but I feel like I'm re-discovering a lot of wheels.

Does there exist a good overview of the "access control" domain, including terminology, discussion of the tradeoffs of different schemes (RBAC, ACL, ???), how it interacts with business policy ("Alice can only access the coffee machine before 11:30"), and possibly implementation suggestions?

Sorry if this question is a bit vague. I'm still in the "I sort of know what I want to accomplish, but I don't know very much about the domain or terminology".

答: Take a look at a security framework such as Spring Security; Spring Security in particular implements a lot of usual security requirements, has good documentation and I suspect well-engineered code (at least Sprinc Core has). You might be able to find a similar framework for your platform of choice, of course.</p>


答:
Had to use this all the time in ActionScript 2 (admittedly now a dead language), because:

```<code>var something:Boolean = org.black.box.unknown.ThisMightNotExistYet();

// this is slightly ambiguous
if(something)
{
}

// because if you allow undefined you might actually mean
if(false != something)
{
}

// which can mean something different than
if(true == something)
{
}

// and comparing against what you actually MEAN is less script than
if(undefined != value && value)
{
}
</code>```

So it was almost always best to be specific.

Title: Make a big deal out of == true?

Body:
Had to use this all the time in ActionScript 2 (admittedly now a dead language), because:

var something:Boolean = org.black.box.unknown.ThisMightNotExistYet();

// this is slightly ambiguous
if(something)
{
}

// because if you allow undefined you might actually mean
if(false != something)
{
}

// which can mean something different than
if(true == something)
{
}

// and comparing against what you actually MEAN is less script than
if(undefined != value && value)
{
}

So it was almost always best to be specific.


问:
Is it common to have stored procedures disabled on MySQL managed hosting plans?
I'm building an app that I think would benefit from the use of MySQL stored procedures. I know stored procedures have a bad reputation, but I think they suit my application well. Using stored procedures would reduce the number of queries per request significantly (mostly inserts), as well as allow me to leverage the procedures across multiple implementations of this software.

I think the software will benefit. My concern however, is that pushing functionality into stored procedures may make it harder for users to deploy the software on shared hosting services. Is it common practice to expect users to have stored procedure capability (i.e. allow scripts to create and run stored procedures)?

Edit: This application is intended for my end user to deploy on her own.

答: I would note that the ability to run stored procedures is a requirement for host of the database for the application into your user requirements documentation if you have a worry about it. Often stored procedures are avoided to allow for different database backends as the different flavors of SQL needed might mean that you have to create different stored procs for each vendor (Complex procs especially tend to use database specific commands). But you seem to be requiring MySQL only anyway, so I would just note it as a system requirement and go on. </p>


问:
New to Programming/objective c
I've recently started to work on some iPhone apps, starting from a base where I had essentially no programming experience (I studied Maths & had very few programming modules)

I worked my way through Beginning Mac Programming: Develop with Objective-C and Cocoa and found it useful, while it gave me the feeling that I needed to quickly address my lack of a real foundation in programming.

For the forseeable future my work will involve developing iPhone apps - I want to have a real grasp of objective-c before things get more pressurised in the coming months.

Is my best bet to study c first of all, before worrying about the finer points of objective-c?

If so has anyone had any experience teaching themselves through an online resource? It would be great if someone could recommend a website with which to self-teach c.

Sorry if this covers some old ground but nothing in the similar questions quite answered my question.

Any help is greatly appreciated :)

答:
May I recommend K&R.

It is a C programming standard.  The book has many exercises and most of the exercises are solved on the web so you can get help when needed.  They even have an answers book (sold separately)

The C Programming Language (Brian W. Kernighan and Dennis M. Ritchie) ISBN 0131103628

This will teach you the lower level stuff, then you can appreciate the high level convenience that the iOS SDK offers.

To improve you objective-c skills in general stick to the basics.  Classes, Memory-management, and read the ViewController Programming guide.

Here is a step by step plan for you.

1) Create an app that you find useful and slightly challenging.

2) Goto step 1)

Before long you will realize what resources you need to improve (whether it is a more solid C programming background, a wider understanding of the available classes within the iOS sdk, or a deeper knowledge of Objective-C and object oriented programming)

Title: New to Programming/objective c


答:
Do you want to know how stepping on the accelerator makes the car go faster, or do you only care that stepping on the accelerator makes the car go faster?

You are seeing the benefit to black box programming, which is a great way to design a system when all the boxes work. Someone has to make the black boxes though and if you want to be that guy/girl then you need to know more about the language than the guy using the box.

There are jobs that are good jobs in each style, so its up to you what you want to program.  IMO you would be doing yourself a disservice though if you didn't put forth the effort to peel back some of the abstraction QT is giving you eventually.

Title: Is Learning C++ Through The Qt Framework Really Learning C++

Body:
The problem I have, is that most of the C++ books I read spend almost forever on syntax and the basics of the language, e.g. for and loops while, arrays, lists, pointers, etc.

But they never seem to build anything that is simple enough to use for learning, yet practical enough to get you to understand the philosophy and power of the language.

Then I stumbled upon QT which is an amazing library!

But working through the demos they have, it seems like I am now in the reverse dilemma. I feel like the rich man's son driving round in a sports car subsidized by the father. Like I could build fantastic software, but have no clue what's going on under the hood.

As an example of my dilemma take the task of building a simple web browser. In pure C++, I wouldn't even know where to start, yet with the Qt library it can be done within a few lines on code.

I am not complaining about this. I am just wondering how to fill the knowledge void between the basic structure of the language and the high level interface that the Qt framework provides?


答:
Programming knowledge is incredibly versatile. If you know how to program, then picking up a language (like objective-c) is as easy as learning the syntax - which you can often find in seconds with a good search engine.

Don't get too caught up on what language you're learning, but what information you're learning. Having graduated(?) with a math emphasis I would feel pretty confident in saying that you have a good grasp of logic, so I'm guessing you have no problems with your standard branching (if, else, functions) and looping (while, for, for-each).

If that's the case, then you'll want to get a good grasp of the other more important concepts (not important because you'll use them more often, but because being able to grasp these other concepts helps you everywhere else). These are some things that helped me:

Concepts/Algorithms

Pointers

Recursion

Tree traversal

Sorting

Prime number generation

Closures

Monads (still haven't wrapped my head around this one)

Sorting

Quicksort

Bubble sort

Data structures

Arrays

Dictionaries

Linked Lists (single and double)

Hashtables/dictionary

Sets

Trees (binary, balanced)

Circular arrays

graphs

The issue with these isn't to say "Oh yeah, I can write X feature" but that they teach you how to think about issues that crop up in programming. So far I haven't written one single linked list, hashmap, or graph traversal. Heck, I haven't used pointers or iterators really at all (at least not the C/C++ variety). I don't even think that I've used recursion. Granted I've been out of school for less than a year... but I definitely credit my current skill and successes to the foundations I laid in school.

Title: New to Programming/objective c

Body:
I've recently started to work on some iPhone apps, starting from a base where I had essentially no programming experience (I studied Maths & had very few programming modules)

I worked my way through Beginning Mac Programming: Develop with Objective-C and Cocoa and found it useful, while it gave me the feeling that I needed to quickly address my lack of a real foundation in programming.

For the forseeable future my work will involve developing iPhone apps - I want to have a real grasp of objective-c before things get more pressurised in the coming months.

Is my best bet to study c first of all, before worrying about the finer points of objective-c?

If so has anyone had any experience teaching themselves through an online resource? It would be great if someone could recommend a website with which to self-teach c.

Sorry if this covers some old ground but nothing in the similar questions quite answered my question.

Any help is greatly appreciated :)


答:
The most damage you will be doing to yourself, if you want to put it that way, is that you will not be learning to use the standard C++ data structures, iterators, algorithms and strings at all. Qt has libraries of its own for all those purposes, and you are all but forced to use them instead of standard C++ entities because Qt APIs only accept data structures of its own.

One could argue that learning to use one algorithms library after mastering other is a trivial task. Before going to an interview where the interviewers expect you to master C++, make sure you deal with that triviality beforehand.


答:
When you mention you need to bolster your programming foundation, I think of language agnostic things like basic logic/reasoning/algorith skills (being able to take a problem and split it into logical steps so you can walk the computer through performing the tasks) and fundamental programming concepts like flow control, value vs reference types (heap vs stack), etc. Since it sounds like you will be mostly working with Obj-C, I'd add in basic OOP concepts as well (what is an object? inheritance, polymorphism, etc...)

Any language (with the caveat that you obviously need to use an OOP language to practice OOP concepts) will help you learn the above. Additionally, there are many non-programming related tasks I like to do to work on my logic - learning more about math, solving brain teasers and puzzles, and learning how to think and solve problems in an efficient manner.

Now, if you have a need to learn Objective-C, there's no reason not to study that exclusively for awhile. At some point, it will definitely be in your best interest to branch out and study a number of languages - my path has taken me all over the place. Obj-C, C, C++. C#, Java, PHP, etc...). The more languages I study, the more I can see and appreciate the pros/cons of each one, and understand why you would use one over the other for a particular project.

However, since you say you will be programming iOS - start with that. Pick up books that focus on iPhone projects. Learn the APIs and methods available to you. There are a ton of great books, blogs, tutorials, etc... which focus on iOS apps and their particular constraints (for example, no garbage collection means you have to be very aware of releasing objects after you are done with them, and understanding retain counts).

Start with what you need to know, and let your curiosity guide you.

Title: New to Programming/objective c


答:
While I agree as a mainly C# developer, I can't say this is always the case.  For instance, in Javascript, the === will perform type coalescence.  So assuming var x = 3 then:

```<code>if(x) --> true
</code>```

while

```<code>if (x === true) --> false
</code>```

I guess that's different than == since even in JS I wouldn't use if(x == true) but just something to think about.

This sort of touches on another point though which has come up in my office:

```<code>bool b = false;
</code>```

In C#, bool b; would be enough and would initalize b to false.  However, it is more explicit to write the above line and anyway should be ripped out by the compiler during optimization.

So I guess my point is it's not always so obvious what is and isn't good practice and a lot of it boils down to preference as well as language features/quirks.

Title: Make a big deal out of == true?

Body:
While I agree as a mainly C# developer, I can't say this is always the case.  For instance, in Javascript, the === will perform type coalescence.  So assuming var x = 3 then:

if(x) --> true

while

if (x === true) --> false

I guess that's different than == since even in JS I wouldn't use if(x == true) but just something to think about.

This sort of touches on another point though which has come up in my office:

bool b = false;

In C#, bool b; would be enough and would initalize b to false.  However, it is more explicit to write the above line and anyway should be ripped out by the compiler during optimization.

So I guess my point is it's not always so obvious what is and isn't good practice and a lot of it boils down to preference as well as language features/quirks.


问:
Are separate parsing and lexing passes good practice with parser combinators?
When I began to use parser combinators my first reaction was a sense of liberation from what felt like an artificial distinction between parsing and lexing.  All of a sudden everything was just parsing!

However, I recently came across this posting on codereview.stackexchange illustrating someone reinstating this distinction.  At first I thought this was very silly of them, but then the fact that functions exist in Parsec to support this behavior leads me to question myself.

What are the advantages/disadvantages to parsing over an already lexed stream in parser combinators?

答:
A lexical analyser recognizes a regular language and a parser recognizes a context-free language. Since each regular language is also context free (it can be defined by a so-called right-linear grammar), a parser can also recognize a regular language and the distinction between parser and lexical analyser seems to add some unneeded complexity: a single context-free grammar (parser) could do the job of a parser and a lexical analyser.

On the other hand, it can be useful to capture some elements of a context-free language through a regular language (and therefore a lexical analyser) because

Often these elements appear so often that they can be dealt with in a standard way: recognizing number and string literals, keywords, identifiers, skipping white space, and so on.

Defining a regular language of tokens makes the resulting context-free grammar simpler, e.g. one can reason in terms of identifiers, not in terms of individual characters, or one can ignore white space completely if it is not relevant for that particular language.

So separating parsing from lexical analysis has the advantage that you can work with a simpler context-free grammar and encapsulate some basic (often routine) tasks in the lexical analyser (divide et impera).

EDIT

I am not familiar with parser combinators so I am not sure how the above considerations apply in that context. My impression is that even if with
parser combinators one only has one context-free grammar, distinguishing
between two levels (lexical analysis / parsing) could help to make this
grammar more modular. As said, the lower lexical-analysis layer could contain
basic reusable parsers for identifiers, literals, and so on.


问:
RESTful HTTP OPTIONS request content
I'm  having trouble determining what I might put in the body of a response to an OPTIONS request? are there conventions? standards? What do you put? do you just provide a list of other METHODS? should you give the representation?

答:
Check out RESTful web services By Leonard Richardson, Sam Ruby

Here's a link to page 98.  "There are no accepted standards."

The methods are part of the ALLOW header.  Not the body of the response.

Title: RESTful HTTP OPTIONS request content


问:
Should a code review be different for front-end web developers?
Web developers code in a minimum of four languages (HTML, CSS, JavaScript, and a server-side language), must produce a working result in several different browser implementations, and may work on the top of a custom software stack that they don't control.

How should a code review take these things into account?

Should a code review include all parts of a front-end project (HTML and CSS as
well), or just focus on the logic?

How should a code review handle workarounds for browser- or stack-specific problems?

答:
Code reviews should cover all the code - that certainly includes the JavaScript and HTML and probably even the CSS.

If you don't have another person proficient in all areas, break the review down into sections so that each can be viewed by another language expert. If you don't have another expert someone will have to become proficient "enough" to be able to ask sensible questions.

If there are any workarounds in the code then these should be checked more thoroughly than the the rest of the code to ensure that they only fire when they should and don't have an adverse affect on the rest of the code.


答:
There is reason why all mature software looks like mess:

All the mess is encoding the critical logic that the business relies on. Without it nothing works. Every bit of it was necessary to solve user problem.

It's using slightly outdated tech. Current programmers seem to think that if it doesn't use some template magic, it's just a mess. This is broken view. Anyone coming late to any bigger project will have this stage while learning all the details.

The requirements which were critical some time ago are no longer so critical. This is because the software already fixed those problems. Coming late to the project, it might seem like the software is complex for no good reason -- the problem no longer exists, but the complexity in the code is still there.


问:
Getting involved in an open-source Python-Java project
I'm a first-year PhD student in Ireland. My background is in mathematics, though I'm going to stream my career into programming with Python, Java and C++ languages. I have some good experience with C++ what allowed me to have a presentation in Europe quite recently - I participated in an open-source cloud computing project. I used Python a little bit in this project, though mainly it was in C++.

I was reading a beautiful "Thinking in Java" book this summer while looking for a PhD. I have no experience in Java. I learned some Python while writing a website based on Django.

I love programming languages since my childhood - I started with Pascal and C. Since then I have not been programming all the time of course.

I know some other auxiliary tools like Git, SVN, SQL, XML and javascript. I want to take my concentration in hands and remember design patterns by the way.

Now...

I have earned some money to have food for 2 years. I really want to find a job, but there is no interesting job on the market or my skills are not enough to get one. So I really want to learn Python and Java in parallel by reading books (have already chosen proper ones), searching google (got used to it) and most important writing code and thus I think to participate in an open-source project again.

Could you please list me 2 or 3 projects in Python and/or Java which are currently active (vivid) and useful?

答:
I don't want to be a doomsayer, but I think your question it just too broad.

There are tons [TONS!] of open projects out there that you could participate in. If you want to get involved I would just find something that interests you and hop right in. If you're into game development, find an open game engine to help with. If you're into compilers, find an open compiler project. Do you want to do embedded systems or OS programming? Do you want to help create an IDE or web browser? The key to contribute is finding a project you are excited or care about and charging ahead with it.

Edit:

Here are some open projects that I know off the top of my head

JAVA:

Eclipse

LibGDX

OwnerDisplayName: Sophie Sperner


答:
In your OP you asked for an instance when using an ORM is "bad". I wouldn't go so far as to say ORM is bad, but it has consequences, not all of which are good.

ORM's generally follow the Active Record pattern* (because Data Mapper is a bit tricky)

this tends to impose design decisions on the database that favour application code

Here's a great quote from an article by Bill Karwin that sums up why this may not be such a great pattern (I couldn't find the thread on SO where it's referenced...): http://karwin.blogspot.com/2008/05/activerecord-does-not-suck.html

A single Model class may be backed by a database table, or multiple
  database tables, or perhaps even no database tables.  Data persistence
  should be an internal implementation detail within a Model; the
  external API of the Model class should reflect its logical OO
  requirements, not the physical database structure.

With regards to "DAL", this is a deceptively simple acronym that encompasses a range of patterns. Personally I prefer using query generators like Zend_DB or NotORM, and writing custom methods to describe the relationships as and when I need to. It takes a bit more hand cranking, but you get intimate with the Domain Model (as opposed to the ORM Model...) and the database that supports it.

There are a couple of classic books on this subject that are well worth a read if you can track them down:

Data Access Patterns : Clifton Nock

Handbook of Relational Database Design

As an aside, it seems somewhat tragic to abandon RDBMS design and the SQL to interrogate it to the application layer! It may not be the new thing on the block, but it's a remarkable bit of technology expressing some very refined concepts that are arguably more robust than the short term design phase that will be applied to the immediate needs of a project. I've seen way too many apps that leave integrity constraints in the application layer, or fail to take into account the indexing/querying methods employed by the DB platform they are using. ORMs are undoubtedly a clever bit of kit, but so is SQL...

Here's another great quote on the subject that expresses this sentiment (with reference to the Table Module pattern:

In many ways this approach treats the relational database like a crazy
  aunt who's shut up in an attic and whom nobody wants to talk about
  http://martinfowler.com/eaaCatalog/tableModule.html

and here is another thread on SO that is very pertinent to this subject:
Constraints in a relational databases - Why not remove them completely?

Title: How can I design a model layer without ORM, and when should I use it?

Body:
I'm a PHP developer who started with CodeIgniter. In it, designing models was easy: it seemed like each method defined in models was the equivalent of static methods in a normal, objected-oriented environment.

I tried FuelPHP, which has an built-in active record style ORM, and PHP ActiveRecord to use with CodeIgniter. I found creating models was easy with ORM, and taught me best practices when designing models.

However, I didn't like that I was tied to a specific ORM implementation, and as I got better with SQL, I thought ORMs were a bit heavy when compared to how quickly I could retrieve stuff with SQL.

But when I try to design models from scratch without ORM, I'm lost: The ORM  system of one class per table and queries with eager loading makes sense, and seems like worth the performance hit for using ORM.

In what situations should I avoid using ORM? How can I design models without using ORM, so that I can use SQL directly?


答:
Under parsing we understand most often analysis of context free languages.
A context free language is more powerful than a regular one, hence the parser can (most often) do the job of the lexical analyser right away.

But, this is a) quite unnatural b) often inefficient.

For a), if I think about how for example an if expression looks, I think IF expr THEN expr ELSE expr and not 'i' 'f', maybe some spaces, then any character an expression can start with, etc. you get the idea.

For b) there are powerful tools that do an excellent job recognizing lexical entities, like identifiers, literals, brackets of all kinds, etc. They will do their work in practically no time and give you a nice interface: a list of tokens. No worries about skipping spaces in the parser anymore, your parser will be much more abstract when it deals with tokens and not with characters.

After all, if you think a parser should be busy with low level stuff, why then process characters at all? One could write it also on the level of bits! You see, such a parser that works on the bit level would be almost incomprehensible. It's the same with characters and tokens.

Just my 2 cents.

Title: Are separate parsing and lexing passes good practice with parser combinators?

Body:
When I began to use parser combinators my first reaction was a sense of liberation from what felt like an artificial distinction between parsing and lexing.  All of a sudden everything was just parsing!

However, I recently came across this posting on codereview.stackexchange illustrating someone reinstating this distinction.  At first I thought this was very silly of them, but then the fact that functions exist in Parsec to support this behavior leads me to question myself.

What are the advantages/disadvantages to parsing over an already lexed stream in parser combinators?


答:
Simply, lexing and parsing should be separated because they're different complexities. Lexing is a DFA (deterministic finite automaton) and a parser is a PDA (push-down automaton). This means that parsing inherently consumes more resources than lexing, and there are specific optimization techniques available to DFAs only. In addition, writing a finite state machine is much less complex, and it's easier to automate.

You're being wasteful by using a parsing algorithm to lex.


答:
Start with objective-C material first - you'll learn a little C in the course of doing that, but for the iPhone you probably want to just do everything the Cocoa way. Learning old school C will not be very useful for that, and will probably just be confusing.

The basic concepts will be similar in both languages, but there's no point in learning two ways of doing things right off the bat - get comfortable with one, then explore alternatives.

Title: New to Programming/objective c


问:
Dependency analysis for tests
Google built a testing system that can infer which tests need to be run after a change. In their own words:

... we built a
continuous integration system that
uses dependency analysis to determine
all the tests a change transitively
affects and then runs only those tests
for every change.

...

Inspired by that, I have created a tool for Python that also uses dependency analysis to detect which tests need to be run. The difference is that it is not tied to a CI system. It is meant to  be run locally and looks for file changes since the last time the tests passed, instead of looking at commits on the version control system.

Visual Studio 2010 has a featured called "Test impact analysis" that "inform the developer of what tests they should run to verify the code changes they are making".

My question is: Is there a name for this approach? I believe I read somewhere that this is called "Incremental Testing", but I cannot find the reference anymore.

答:
I'd call it regression testing.  Or perhaps automated regression testing.

From the link:

```<code>Regression testing can be used to test a system efficiently by systematically
selecting the appropriate minimum set of tests needed to adequately cover a
particular change.
</code>```

ContentLicense: CC BY-SA 4.0

Title: Dependency analysis for tests

Body:
I'd call it regression testing.  Or perhaps automated regression testing.

From the link:

Regression testing can be used to test a system efficiently by systematically
selecting the appropriate minimum set of tests needed to adequately cover a
particular change.


问:
Make a big deal out of == true?
There is a colleague of mine who constantly writes:

```<code>if (someBool == true)
</code>```

It drives me up the wall!  Should I make a big deal of it or just drop it?

答: Actually, if it's nullable, testing for x == true would be necessary. :)</p>

Title: Make a big deal out of == true?


问:
Empirical Evidence of Popularity of Git and Mercurial
It's 2012! Mercurial and Git are both still strong.

I understand the trade-offs of both. I also understand everyone has some sort of preference for one or the other. That's fine.

I'm looking for some information on level of usage of both. For example, on stackoverflow.com, searching for Git gets you 12000 hits, Mercurial gets you 3000. Google Trends says it's 1.9:1.0 for Git.

What other empirical information is available to estimate the relative usage of both tools?

答:
I think other than Google trends or SO questions (which as the comments above point out, might indicate curiosity or difficulty rather than usage), your best bet is to look at statistics where they are available, and weight them by source (how you do that is likely suggestive, though).

You can see the distribution of ALL version control systems on projects indexed with Ohloh.

Debian Popularity Contest shows a graph for stats for DVCS packages.

And it's a little outdated, but the GNOME DVCS Survey Results are interesting.

When it comes down to the numbers, I think Ohloh is the most general audience, so I'd go with that, personally... still a LOT of people using SVN and even CVS, though.

In terms of open source software, where the important issues are coordinating broadly distributed and asynchronous teams, Git is the hands-down winner. Especially when you look at Wikipedia's comparison by popularity of open-source project hosting sites (based on numbers of GitHub (git) vs. BitBucket (Hg)).


问:
Process of developing software?

Possible Duplicate:

  What to plan before starting development on a project?

I was wondering when you start developing a software what process should you generally go through to do it?

By this I mean after you get an idea, do you just sit down and start pushing out code directly, or is there some planning process that you should generally go through first? (i.e. flowcharts, diagrams etc.)

Just wondering because I just had an idea and am about to embark on my first "real" application but have no idea where to begin. What would you suggest is the steps that should be taken to have a successful developmental cycle?

答: It really depends on how big the application is going to be. However, if it is a "real" application, it wouldn't hurt to do a little pre-planning.  First, identify the major components of the application, and try and establish a rough interface between them.  Next, develop each major component independently, utilizing stubs to test them. Establish that each one works as expected given the interface / public API.  Then hook everything together, and verify the application as a whole.</p>

Title: Process of developing software?

OwnerDisplayName: Jonathon Reinhart


答:
An application is really nothing more than a collection of actions realized in software.  The simplest application would have one action (e.g. "list all the individuals in the club in the browser"); more complex ones have more (e.g. "add a new member to the club", "remove an existing member from the club", "promote a member to the rank of president").

You should at least have a clear enough idea of what you want to do to be able to list out all the actions you want your application to perform.  If you can't write them out clearly in your native language, it's unlikely you'll be able to write them in software.

You should make some rough decisions about how you want go about it.  Who will use it?  Is it a desktop app?  Mobile?  Web?  Command shell, text driven?  Batch?

How will you persist data?  File system?  Relational database?  NoSQL?  Something else?

Sketch out the main components.  Some people like UML, but boxes and arrows are sufficient.  A rough mental picture that's easy to keep in mind is helpful.

Once you have those, start coding.  Take small bites: Write some code, test it, put it aside, work on the next piece.  If you can write all the pieces to accomplish one of your actions, test it out and move onto the next one.

Title: Process of developing software?

Body:
Possible Duplicate:

  What to plan before starting development on a project?

I was wondering when you start developing a software what process should you generally go through to do it?

By this I mean after you get an idea, do you just sit down and start pushing out code directly, or is there some planning process that you should generally go through first? (i.e. flowcharts, diagrams etc.)

Just wondering because I just had an idea and am about to embark on my first "real" application but have no idea where to begin. What would you suggest is the steps that should be taken to have a successful developmental cycle?

OwnerDisplayName: duffymo


问:
Can you call any php model class in an MVC from the controller?
I'm creating a simple MVC at the moment and am wondering if it's 'correct' to be able to call any model class directly from the controller to get the data to send to the view?

I have the following folder structure:

```<code>.htaccess
index.php
/controller
/model
/templates
</code>```

I also have the needed model classes within the /model folder, at the moment I've tried playing with a /model/model.class.php to try and build all parts of the site but it's already starting to become huge and I think it might be better to completely cut it out.

I'm thinking the better approach is to use:

```<code>elseif($_GET['type'] == "Profile") {
    $profile = new thread($userId);
    $comments =  $profile->getComments();
    require "templates/profile.php";
}
</code>```

The above is a brief example but is that how a controller could/should/might look or was the first approach better or am I completely missing the point of the model and controller communication?

答:
I'm not sure I completely understand your question, so I apologize if I misinterpreted it.

A controller may have an access to any model of your application. There is no reason to assign a set of models to every controller, and to restrict the access to those models only.

Now, a model is linked to a view (if the view requires a model). If the view HomePage expects the model RecentPosts, the controller has to provide the initialized RecentPosts model to the view.

It's up to the controller to decide where and when to call a view and to pass to it a model this view requires.


答:
One of the main arguments for Behavior-Driven Development is that it force you to think first in terms of user stories, scenarios, and features. Writing the tests first is a great way to organize at least the behavior of the application before you dive into building it.

Paul Graham advises diving right in rather than doing a bunch of planning for programming projects of any complexity. While this sounds counterintuitive, building a prototype that you intend to throw away is one of the best ways to understand the problem domain before you get attached to a specific model.

My general methodology for a significant or important (at least to me) project is:

Develop the prototype to understand the interactions and have a sandbox in which to experiment

Develop a basic feature list, with implementation ideas based on my prototype

Write unit tests, then code to the tests

Red, Green, Refactor.

Title: Process of developing software?


问:
Can you give me an example of your Continuous Integration development process
We are thinking of doing Continuous Integration with nightly builds here.  Some of our sticking points is when to do code reviews.  Is anyone out there doing Continuous Integration with nightly builds AND doing code reviews?  If you can give a brief outline of your process that would be great.  For example, here's what we are doing now:

Developers attempt to check in code daily or as often as possible.  Code does not have to be "done", it merely has to compile.  They rebase their code with everyone else's changes at this time.  Doing this often prevents us from merging nightmares.

Builds come out nightly, but QA only looks at the builds but doesn't write up bugs yet, they merely inform us of what they are seeing.

Every few days, we have an official release.  Code is Reviewed.  We write up a description of what is ready for testing, what isn't.

QA writes up what they find in the stuff we say is ready for test.  The process starts over.

So, what are we doing wrong?  One thing I don't like, is that code is checked in that isn't reviewed.  I heard before, that code should only be checked in that's been reviewed, however, I'm not sure how to do that and still have programmers check-in code daily.  If you can give examples of what your process is, I'd really appreciate it?

答:
At work I've set up a process with Git and Gerrit and some custom CI scripts. Here's how it works:

All work is done on branches and merged into master later.

As developers work, they check in changes to Gerrit, where they are reviewed by others. Gerrit keeps the unreviewed changes in a separate holding area from the reviewed branch itself.

When a branch is complete, it's merged into master and then the merge commit is also submitted to Gerrit for approval.

The autobuild script builds the following: (a) master branch, (b) all reviewed work branches, and (c) any unreviewed code in Gerrit.

Gerrit manages the review process well and allows people to check in changes for review at any time, but they can't surreptitiously or accidentally change them after the review has passed.

Our environment is critical production software where all changes must be signed off before inclusion (that's why the merge commit goes through Gerrit as well). Separating the review of the changes from the merge commit review means that those two steps can be done at different times. Reviewing code doesn't necessarily mean it goes live.

OwnerDisplayName: SpecialEd

OwnerDisplayName: Greg Hewgill