问:
Decoupling UI code?
In my application I have several event handlers that perform some action in response to user interface events such as a button click or menu selection.  The code in these event handlers looks like this for example:

```<code>void MyDialog::OnCommandLoadFile()
{
    char strFilter[] = { "Text Files (*.txt)|*.txt|All Files (*.*)|*.*||" };

    CFileDialog fileDlg(TRUE, ".txt", NULL, 0, strFilter);

    if( fileDlg.DoModal() == IDOK )
    {
        const std::string path = fileDlg.GetPathName();

        std::vector<std::string> urls;
        int maxNumberOfUrls = settings_->Get<int>(Settings::MaxNumberOfUrls);
        UrlProvider *urlProvider = new FileUrlProvider(path);
        urlProvider->GetUrls(urls, maxNumberOfUrls);

        webMonitoringService_->MonitorUrls(urls);

        DisplayMessage("URLs loaded.");
    }

}
</code>```

This is typical of my event handlers. I don't code monolithic event handlers but they do "glue" various pieces together.  I usually have some business-logic/service classes which the UI has a reference to and in the event handlers I make calls to one or more of these to perform the desired task.

What I'm wondering is is this still too coupled?  If I wanted to turn this into a command line app I'd have to extract bits and pieces from the UI code.  In the above example, there is a compound action going on so should I'm thinking it should look more like:

```<code>void MyDialog::OnCommandLoadFile()
{
    char strFilter[] = { "Text Files (*.txt)|*.txt|All Files (*.*)|*.*||" };

    CFileDialog fileDlg(TRUE, ".txt", NULL, 0, strFilter);

    if( fileDlg.DoModal() == IDOK )
    {
        const std::string path = fileDlg.GetPathName();

        application->MonitorUrlsFromFile(path);

        DisplayMessage("URLs loaded.");
    }

}
</code>```

Is that right? In the above code what would "application" be?  A controller?  Is that the right abstraction for this?  Whenever I need to perform some task in a UI handler, should it always be a one-liner (aside from getting data in or out of text boxes etc.)  Anyone have a pointer to a tutorial that really covers this (in any programming language)?

Furthermore, if in fact you should abstract compound actions, how to you propagate error messages from within the compound abstraction back out to the UI?  An exception hierarchy? Single exception with error code?

UPDATE

I'm looking at the Command Pattern which looks promising.

UPDATE 2

In the end I decided on refactoring my code as described in the Humble Dialog Box paper in the accepted answer.  My understanding is that this is a Model View Presenter (MVP) type pattern and more specifically a Passive View.  The refactoring is going smoothly.  There are some rough edges in my understanding of the full application of the pattern when it comes to things like displaying message boxes and file open dialogs or dealing with event timers but overall I'm happier with my code; the tight coupling was bothering me.

I also found this "bundle": patterns & practices Web Client Developer Guidance: Model View Presenter (MVP) Bundle which has sample MVP code.  It's a web project whereas my current implementation is desktop but I guess that's the beauty of MVP is that it partly doesn't matter.  One thing I got from that was to dependency inject my service layer objects into the presenter rather than new'ing them inside my presenter class.

答:
If you want to learn how to better decouple your GUI from your business logic, I suggest you read Michael Feathers` article "The humble dialog box"

If you got yourself familiar with that, and you want some more of that stuff, here is a Blog series "Build Your Own CAB" which explains all important variants of "MVC":

https://web.archive.org/web/20200715030107/http://codebetter.com/jeremymiller/2007/07/26/the-build-your-own-cab-series-table-of-contents/

EDIT: according your example code: when you are going to use "MVP", that will mean not to have a "god object" application where you place MonitorUrlsFromFile, but a controller (or "presenter") class MyDialogController at first hand. Think of it when your program get 20 dialogs and all of them would place their handler logic in a class application - that will easily end up with a class having 5000 lines of code or more, which is definitely too big.

By MVP approach, you will only refactor MonitorUrlsFromFile to another more general place, when you need this function from more than one dialog and want to reuse it. Even then I would not make this an application class, better group functions for urls or url monitoring into one utility class.

Title: Decoupling UI code?


问:
Do exceptions basically exist to prevent a system from crashing?
Second of all, I was wondering if anyone knew what the difference was between exceptions (in the realm of exception control flow) and Exceptions (such as used in Java).

But are they there to basically protect the system from crashing by terminating the user program?

答:
Exeptions exists to separate normal program flow (what the program is designed to do) from the error handling flow (how program is trying to recover from an exceptional situation).

This makes code more clear and easier to maintain.

Consider two code sniplets:

```<code>try:
    do1()  # this is obvoiusly a normal
    do2()  # program flow
except:
    oups()  # this is exception handling code
</code>```

Compared to this one:

```<code>if foo():
    thing1()  # is this part of normal program flow?
else:
    thing2()  # or maybe this one? Or both? When?
</code>```

Of course, exception handling can be used to prevent program from crashing by:

```<code>try {    // very bad code
    my();
    whole();
    ugly();
    application();
    here();
} catch (Throwable t) {
    // pretend it's ok
}
</code>```

but this is not the reason for the exceptions in modern programming languages.

You can also use while and break instead of if but this is not what while and break are for.

ContentLicense: CC BY-SA 3.0

Body:
Exeptions exists to separate normal program flow (what the program is designed to do) from the error handling flow (how program is trying to recover from an exceptional situation).

This makes code more clear and easier to maintain.

Consider two code sniplets:

try:
    do1()  # this is obvoiusly a normal
    do2()  # program flow
except:
    oups()  # this is exception handling code

Compared to this one:

if foo():
    thing1()  # is this part of normal program flow?
else:
    thing2()  # or maybe this one? Or both? When?

Of course, exception handling can be used to prevent program from crashing by:

try {    // very bad code
    my();
    whole();
    ugly();
    application();
    here();
} catch (Throwable t) {
    // pretend it's ok
}

but this is not the reason for the exceptions in modern programming languages.

You can also use while and break instead of if but this is not what while and break are for.


问:
Should I expect recent grads to be familiar with basic programming concepts?
It seems there's a HUGE discrepancy between what I expect someone who's studied programming for a few years at university, and what one actually knows.

I don't feel like I'm asking overcomplicated questions in interviews. Some of my usual questions are :

What's the difference between a reference type and a value type?

If it seems the interviewee doesn't really understand his own answer, or if he doesn't know the terminology I'm using, I get into more details by asking him to explain me what happens when I write int i=0; in a method, what about object o=0, object o = new MyClass(), etc...

Basically, I do everything I can to trick the interviewee into telling me about the callstack, the heap etc, and I try to stay into language-agnostics concepts. If the interviewee tells me he did a lot of C, or C++, or c#, I dive deeper into the specific language, and possibly into the implementation details.

If needed, I ask the interviewee what a callstack is, or where arguments passed to a function in the imperative language of his choice are stored.

most of the interviewees have just no idea about what a callstack is, let alone boxing considerations, etc.

What's the difference between an abstract class and an interface. In which cases should you use one over the other ?

Usually, I also ask them to imagine a design of a small library with a use case aiming at using some inheritance and some abstract factories

Most of the interviewee have just no idea of what inheritance real purpose might be. They usually know some keywords (virtual, override, etc), but don't really know when to use them, let alone explaining what a virtual-table is.

Even-though I screen CVs beforehand, even for people with 5 years of experience in real life projects involving complex architectures, I would say less than 25% of all my interviewees can answer those two questions properly. And when I say properly, I don't mean 'in-depth'... just to have an approximate idea of what the concept is.

Regarding juniors, I'm fine with hiring someone who doesn't know how to organize his time very well, or someone who's not used to industrial build processes for example, but I have the feeling that if one hasn't heard the word "callstack" after a few years of studying Computer Science, he's either stupid, or unmotivated, or chose his university very unwisely.

Do you think I'm too extremist here ? Is it common to learn these basic concepts after you've completed university ? Do you know of people who weren't familiar with these, and became very good software engineers after a few years ? And do you think my company might have an issue in attracting talented people, or do you experience the same kind of issues with in your own hiring process?

Edit. regarding the "immediate type" thing, it was just a literal translation from French to English, as we usually do our interviews in French. I've fixed it in my question. But still, I think you all understand perfectly what I meant, which kind of makes my point, doesn't it?

答:
You have quite a number of narrow views and you do assume them implicitly.

It seems there's a HUGE discrepancy between what I expect someone
  who's studied programming for a few years at university, and what one
  actually knows.

To my knowledge there's no university, where people study programming for a few years. Universities offer courses in computer science, whereof programming is one aspect.

What's the difference between a reference type and a value type?

Rule of thumb: If Lisp can do without the distinction, it's only clutter ;)

Basically, I do everything I can to trick the interviewee into telling
  me about the callstack, the heap etc, and I try to stay into
  language-agnostics concepts.

Talking about language-agnostic concepts is a good idea. Neither the heap nor the stack are language-agnostic though.

If the interviewee tells me he did a lot of C, or C++, or C#, I dive
  deeper into the specific language, and possibly into the
  implementation details.

All these languages have specifications. Implementation is undefined by the language. C and C++ can be cross-compiled using LLVM to run on the Flash Player or any JavaScript runtime. This makes your assumptions about heap and stack allocation void.

With C#, it's much the same. C# is JITed before execution with a lot of optimization, that can be done. Local variables, that are captured by closures will ultimately wind up on the heap, instead of the stack, while escape analysis allows to store scope-local objects (that should normally go to the heap) to be stored in the stack. Proper register allocation will also greatly reduce the need for stack allocation.

If needed, I ask the interviewee what a callstack is, or where
  arguments passed to a function in the imperative language of his
  choice are stored.

What would you ask someone who's only extensive programming experience is with Haskell? :P

Most of the interviewees have just no idea about what a callstack is, let alone boxing considerations, etc.

The basic idea behind autoboxing is, that primitives can also be treated as objects (or at least values who's type can be discovered at runtime). In regard to that abstraction, there's three types of languages:

those where it doesn't exist. I suppose Objective-C is the cannonical example.

those where it truly holds

those where it exists but doesn't hold. I guess Java is the best example (I'd assume it has been fixed by now).

I don't see why people shouldn't be using languages of category 1 (actually it's a good idea). I don't see why people who use languages of category 2 should really bother. And I think everybody who uses a language of category 3, i.e. one where a core semantic feature is simply broken, is using the wrong language.

What's the difference between an abstract class and an interface. In
  which cases should you use one over the other?

Now that is highly subjective and really depends on the language. C++ doesn't have interfaces. Objective-C doesn't have abstract classes. I would argue that any language that has both is in grave need of redesign. Many modern languages use traits, mixins, categories, roles and similar constructs to provide far cleaner solutions for code reuse than inheritance of partial implementations. Prototype based languages don't have classes altogether anyway.

Ultimately this is a difficult and contested subject. An interview is hardly the right place to solve this question and I wouldn't really nail anyone applying for a junior position on not giving me a good answer.

Most of the interviewee have just no idea of what inheritance real
  purpose might be. They usually know some keywords (virtual, override,
  etc), but don't really know when to use them, let alone explaining
  what a virtual-table is.

There's a number of object oriented languages, that don't use inheritance or classic vtables.

My advise:

Be very careful to assume that anything you know about programming is really a basic programming concept. You can assume that every good programmer has the curiosity to find out the answers to such question. However you cannot assume that anyone who knows them is good. I tend towards believing that those giving too much importance to such details are actually likely not to see the forest for the trees.

Worry less about implementation details. Programming languages are meant to create abstractions. You need to think in terms of those abstractions and in terms of them only. Good code is not written against implementation details of a language. It is written to best embed the semantics of your solution into the language features. If you succeed in doing that, your code will not only become robust, but well readable for anyone familiar with the language, and easier to optimize for a compiler.

Knowing the answers you expect is not so important. Understanding them is. If somebody just knew them, because they read them in a text book or his professor told them, then it's of little value. Actually you can explain all those things to yourself with a matter of hours.

What is important is you understanding of how these simple and isolated facts can be applied to engineering flexible and maintainable solutions to complex problems.

To get to the real question:

And do you think my company might have an issue in attracting talented
  people, or do you experience the same kind of issues with in your own
  hiring process?

All companies have issues attracting skillful people, except maybe the big players. That's because there's few of them. And because of the assumption, that university renders people skillful. It doesn't. It renders them knowledgeable (supposing both the student and the university hold up to their part of the bargain). Experience is what makes people skillful.

There are a few who have collected experience prior to entering university and who carry on doing so during their studies. Because they like programming and because when they pick up some new idea during a course, they will try to see how they can put it to use, the first thing they get back home. This is the kind of people you would love to hire. But there's few of them.

It is the passion for programming and self-improvement and its pursuit that make programmers good. In time.

I think, what you must realize is, that sadly most people will enter and leave university without sufficient programming experience.

At the same time, our industry is in bad need of experienced programmers. Therefore, I believe it's our industry's mission to actually try to step in. And interviewing candidates for junior positions, what you're realistically looking for is people willing to learn and to improve. And you should choose carefully, because you will need to invest a lot of energy and you don't want that to go to waste.

Think of it as hiring a fresh blood to become a driver for your racing team: A good driver has a sufficient understanding of mechanics to make best use of his car, but this knowledge alone is of no use (it's not even much of a head start). What you're looking for is someone willing to work hard on their own improvement and well with your team.


问:
Is there such a thing as a "when" statement?
Is there a language or language feature that can handle "when" cases? That is, whenever some condition becomes true, in any scope or context, that extra code could be specified to execute?

Note that this is different from a simple if, which must be in a particular scope and explicitly written. This when clause would almost be like an if that applied to every case in the execution of the program after it.

答:
Lisp (and its many dialetcs, including Scheme) has it:

```<code>(when (> 2 1) 'do-something)
</code>```

evaluates to do-something and:

```<code>(when nil 'other-thing)
</code>```

evaluates to nil or its equivalent.

Body:
Lisp (and its many dialetcs, including Scheme) has it:

(when (> 2 1) 'do-something)

evaluates to do-something and:

(when nil 'other-thing)

evaluates to nil or its equivalent.


问:
Is the agile approach too much of a convenient excuse for cowboys
I believe that an agile approach is best for projects where the requirements are fuzzy and a lot of interaction is required to help shape the end user's ideas.

However... In my professional work, I keep ending up at companies where an "agile" approach is used as an excuse as to why no effort was put into an up front design; when the requirements are well understood.

I can't help but thinking that if the agile approach wasn't around, I'd be sitting here with a nice high-level specification and not having to revisit the same screen and functionality every second day when something else crops up or so and so hadn't thought of that.

Are the benefits of agile methodologies really enough to outweigh the excuse for being lame it gives to cowboy technical leads?

Update: Ironically I'm now a certified Scrum Master. One of the papers presented on the Scrum course observed that the best development process was one where there was a single expert or guru making the design decisions, however that has obvious weaknesses. Scrum shifts the responsibility for producing quality software to the "Team" which means a sub-standard team can get away with churning out spaghetti which I guess is no different to other Agile and non-Agile development processes.

答: Its funny how nobody thinks of themselves as cowboy coders. Im betting many of the posters are or have been one ;)</p>

ContentLicense: CC BY-SA 2.5


答:
The description sound like a database trigger which is designed to await a certain scenario and then execute.

From Wikipedia:

A database trigger is procedural code that is automatically executed
  in response to certain events on a particular table or view in a
  database. The trigger is mostly used for keeping the integrity of the
  information on the database. For example, when a new record
  (representing a new worker) is added to the employees table, new
  records should be created also in the tables of the taxes, vacations,
  and salaries.

http://en.wikipedia.org/wiki/Database_trigger

Title: Is there such a thing as a "when" statement?

Body:
Is there a language or language feature that can handle "when" cases? That is, whenever some condition becomes true, in any scope or context, that extra code could be specified to execute?

Note that this is different from a simple if, which must be in a particular scope and explicitly written. This when clause would almost be like an if that applied to every case in the execution of the program after it.


问:
Definition of a 3-tier system
People often claim that they are following a '3-tier (or n-tier) architecture', and sometimes they then claim to be switching to a Domain Model. But I really never have understood what this mythical '3-tier architecture' is. It seems to have no formal definition. Whereas there are numerous references and examples around that explain and demonstrate the Domain Model pattern, any reference to 3-tier simply suggests you should separate your code into UI, Business Logic and Data Access Layers. And that's all they seem to say.

What I find particularly strange is that to me, Domain Model is the perfect embodiment of this 3-tier paradigm. the ORM and mapping files are the Data Access Layer, the Domain is the Business Logic, and the UI is the, well, UI. So why do people talk as though it is something new and different, and something they should switch to?

Before I saw people implementing Domain Model, most applications were UIs accessing stored procedures with the logic split across the UI and the SPs. Sometimes there were a few assemblies called 'UI', 'BLL' and 'DLL' but usually these were just mediators between the UIs and SPs, leaving more places for the logic to be randomly spread across.

So what is this mythical '3-tier' architecture? Does it really even exist? and if so, where are some examples of it implemented well?

答:
The definition of 3-tier architecture is a special case of the n-tier architecture. In an n-tier architecture, there are n components and each one only interacts with the component immediately "above" and "below" it. A three-tier architecture has three such components.

Typically, a three-tier architecture consists of a user interaction layer, the business rules layer, and data services (including databases) layer. The user interaction layer only issues requests to the business rules layer, which retrieves data from the various data services, processes it, and then returns it to the user through the user interaction layer.

The n-tier architecture is an example of an architectural pattern (or architectural style). It simply defines some constraints on the architecture of the system. By itself, it is not a complete view of the architecture of the system. Although I'm sure that there are systems that implement something like a three-tier architecture, it is just a pattern that's meant to set up a discussion for additional design and implementation of a system.

Title: Definition of a 3-tier system


问:
How can I make the life of a new hire comfortable?
As a senior member of a software team that, unfortunately, has little documentation for legacy reasons, what are the things that one could do to make a new hire comfortable?

I have been planning debug sessions with the person on specific defects/feature requests to get him/her acquainted with the code base. However the code base is real large, and its only a fixed amount of code I can expose the person to in this manner.

I am looking for suggestions in either cases when the new hire is a recent graduate or an experienced professional.

答:
In addition to what have been said before, identify training needs and provide for it either by providing time, material, in-house classes, books, etc. Chances are not every one knows everything. Make him/her aware that this is OK.

Keep him/her away from 'bad' guys. There are usually at least 1 arrogant person in every organization (this is my law :))

If you assign a mentor, make sure the mentor knows that it is the mentor's job to help and it is not out of his kind heart. Make time in the mentor's schedule for that.

Follow-up on his progress the first month or so, infer his problems if you can.


问:
Start to understand an existing project for beginner programmer
I want to understand an existing project to improve myself more, but I am not sure if the project would be overwhelming for me or not. I am not sure if I am capable of understanding it. I even think that I will fail. When I look at projects at a glance, it makes me feel scared to see thousand line of codes.

I don't even know where to start reading code. Do I have to follow by debugging or is there something else?
Can you please guide me in this situation? I am totally getting confused at the start.

Edit : A few thing to specify about my question.

I know C# language and I have learned some WEB technologies like ASP.NET, MVC 2, and Web Forms but I am sure there still will be many thing which I don't know. I label myself as beginner but it is just because of a lack of professional experience in this area. But my OOP understanding is good enough. I am wanting to improve myself on WEB, so I am looking for WEB projects like blog engines which are simpler than others for starting.

答:
Best is to start off by fixing bugs. Start with small bugs. Fixing the first bug is a big milestone. Because when you do that, you already know how to edit version controlled code, build it, understand the desired functionality and test it. You also know the conventions used, libraries available, idiom/riffs used, debugging techniques, coding style/conventions of the project, overall code organization, the bug tracking system used etc.

Do not be overwhelmed by the size of the project. Start small. Start with easy bugs. Ideally your mentor should assign something simple enough to get you familiar with your development environment. Then move on to small features, in modules that you are already familiar with. Then you can move on to more complex bugs or move to adjacent modules. In time you will be able to think in bigger chunks of the project and the size will suddenly seem smaller.


问:
What were the reasons why Windows never had a decent shell?
I was reading a topic on SO: Why are scripting languages (e.g. ...) not suitable as shell languages?. Especially I liked the answer by Jörg W Mittag, from which I learned interesting things about Windows PowerShell. So after more than 20 years Windows finally has a well designed shell (Windows 1.0 - 1985, PowerShell stable release - 2009). On other hand Unix systems has a bunch of various shells since 1978 Bourne Shell. I've read some articles about MS job interviewing and I have an impression of very "geekish" company. I am wondering why didn't they had a need for command-line tools compared to Unix people who do all their work with those tools.

答:
When it was launched, in 1993, Windows NT was a move by MS into the space previously occupied by Unix servers and at the time a big deal was made about POSIX compatibility and portability.
But it didn't quite do the job - instead its users were more the desktop crowd using better hardware (these were the days when a 486dx 50MHz with 32MB of RAM was close to the top end) and wanting a better OS. But they weren't interested in shells, so that all slipped.
By the time of Windows Server 2000, which was a second serious attempt to crack this market I think MS had realised they were weak on the shell side - as admins love shell scripts - but even then it took them some time to scratch the itch.</p>


问:
Is there an alternative to Google Code Search?
Per the Official Google Blog:

Code Search, which was designed to help people search for open source
  code all over the web, will be shut down along with the Code Search
  API on January 15, 2012.

Google Code Search is now gone, and since that makes it much harder to understand the features it presented, here's my attempt to render them via information I gathered from a cache of the page for the Search Options:

The "In Search Box" just notes the syntax to type the command directly in the main search box instead of using the advance search interface.

Package (In Search Box: "package:linux-2.6")

Language (In Search Box: "lang:c++")

(OPTIONS: any language, actionscript, ada, applescript, asp, assembly, autoconf, automake, awk, basic, bat, c, c#, c++, caja,
cobol, coldfusion, configure, css, d, eiffel, erlang, fortran, go,
haskell, inform, java, java, javascript, jsp, lex, limbo, lisp,
lolcode, lua, m4, makefile, maple, mathematica, matlab,
messagecatalog, modula2, modula3, objectivec, ocaml, pascal, perl,
php, pod, prolog, proto, python, python, r, rebol, ruby, sas, scheme,
scilab, sgml, shell, smalltalk, sml, sql, svg, tcl, tex, texinfo,
troff, verilog, vhdl, vim, xslt, xul, yacc)

File (In Search Box: "file:^.*.java$")

Class (In Search Box: "class:HashMap")

Function (In Search Box: "function:toString")

License (In Search Box: "license:mozilla")

(OPTIONS: null/any-license, aladdin/Aladdin-Public-License, artistic/Artistic-License, apache/Apache-License,
apple/Apple-Public-Source-License, bsd/BSD-License,
cpl/Common-Public-License, epl/Eclipse-Public-License,
agpl/GNU-Affero-General-Public-License,
gpl/GNU-General-Public-License,
lgpl/GNU-Lesser-General-Public-License,
disclaimer/Historical-Permission-Notice-and-Disclaimer,
ibm/IBM-Public-License, lucent/Lucent-Public-License, mit/MIT-License,
mozilla/Mozilla-Public-License, nasa/NASA-Open-Source-Agreement,
python/Python-Software-Foundation-License, qpl/Q-Public-License,
sleepycat/Sleepycat-License, zope/Zope-Public-License)

Case Sensitive (In Search Box: "case:no")

(OPTIONS: yes, no)

Also of use in understanding the search tool would be the still live FAQs page for Google Code Search.

Is there any code search engine that would fully replace Google Code Search's features?

答:
Try this: Koders

Edit

Update: Koders has merged with Ohloh.


答:
I know such a kind of statement only for error handling. For example, BASIC's ON ERROR ... or SQL*PLUS's WHENEVER SQLERROR ...

For arbitraty conditions, it would require either an extremely clever compiler or a rather expensive kind of brute force (check after every statement) to catch the exact moment when the conditions becomes true.


问:
Standards in Enterprise Development
Is it perhaps time for enterprise systems to be developed to strict enforced standards? Many books list optional 'standards' and best practices, but these are purely suggested practices. Still, every time I look at the code for an enterprise system I have not been a part of, I spend a lot of time trying to work out the architecture.

Should we not have some form of ISO accreditation for our systems? We could have a selection of standard architectures such as Domain Model, Transaction Script etc, but once we choose one of these, we have to follow a strict architectural template. Systems could be audited to ensure we are working to these standards, and our companies would carry this accreditation.

This would be better for developers because when we take on legacy work that was written by another company, we will not have to spend time deciphering the architecture.

It would benefit clients because they would know that if they used the services of an accredited development company, they could used another company to maintain/amend it, and not be tied to the original developers.

答:
Standards sound all fine and dandy, but what happens when a customer has performance needs or a different business model that are impossible to achieve without a unique architecture? Each customer has to make an informed choice about the advantages and disadvantages of different solutions. Developer Lock-In is just one concern.

Are programmers going to have to be certified for specific standards? Are we going to create governing bodies that will send software inspectors to verify compliance? Home electrical wiring specifications in Australia have no need to comply with Asia. Software can span the world. What will be the level of compliance? Absolutely 100%? Seems like the burden of policing this would fall on clients who will have to report violations. Do they have the time, expertise and resources?

Even companies that create their own internal apps have to deal with a new generation of developers that have to get up to speed and they're not always provided the best documentation or supervision.

Situations where a standard is applicable probably doesn't have enough new development in these areas to warrant a standard.

Title: Standards in Enterprise Development


问:
Need advice on which route I should take for porting app from Android to iOS
I have developed this android application  and I am looking to port it to iOS.

My questions are:

1) I am planning to finance the iOS development with the money earn't from the android sales which is about $200 at the moment. Would it be reasonable to get the project done for this amount even if it is outsourced to elance or odesk etc?

2) I have heard the code quality for outsourced iOS projects to be bad, I dont want any memory leaks and crashes because of overflows etc.

3) I currently dont have a full time job so I can technically do the project myself, however I dont have a apple pc or iPhone (dont really want to get them either).

I know C pretty well but I haven't really released a major C project that must be 100% stable. How many hours to learn iOs and do the port? And would it be worth my time taking into consideration that if I do enjoy it I may get into it fulltime.

4) What would the demand be like for someone that can do Android and iOS?

Thanks

答:
well why you thinking about other people  to port your application ? It has many disadvantages

1) You giving away your android code.

2) What if you update your app , you cant sure weather the first person who worked for it will available again , you will end up searching for another guy, who has to understand previous code  in order to  add any new functionality .

on the flip side

If u really coded that android app yourself then learning objective c is not that difficult.Oh wait you talking about hours to learn ios programming ? are you kidding ? .

My suggestion is learn objective-c ,and do it yourself ,it may take some time but trust me in long term you will be benefited.

Resources to learn ios programming :

1)Beginning iOS 5 Application Development (book)

2)If you need  sample code about a particular class,Browse through apple documentation code. (its pretty good)

P.S : You can use VMware to install mac on windows (but its illegal according to apple world!) ,Try to learn and code in that virtual machine until you get enough money to buy a new macbook pro ( you can find used ones cheap in craiglist)


答:
What you're talking about is less syntax than structure.  You could really only have a when statement like that in a system that executes a finite amount of logic, then executes the when statements, then loops around and executes the logic again, continuing in an infinite loop.

For instance Windows programming is typically "event based".  Subscribing to a button's Click event essentially means "do this when clicked".  However, what's going on under the hood is a message processing loop.  Windows sends a message to the application when the user clicks the button, and the message processing loop in the application runs the appropriate event handler.

If you use events in, for instance, C#, you can do this without a message loop, but the limitation is that you have to declare the event ahead of time, so you can't write an artibrary when statement that watches for any kind of state.  You have to wait for a specific event.

To get this behavior in a Von Neumann Architecture you have to run some kind of infinite loop that checks for all the conditions every time through the loop running the appropriate code if appropriate.  Internally you just get a big list of if/then or switch statements.  Most desktop application and web programmers would vomit if they saw such a construct so it's really only palatable if you wrap it in some kind of syntactic sugar like the Windows event model (even though that's what's going on under the hood).

On the other hand, if you look at the field of embedded firmware development, real-time executives, or industrial controllers, this model of programming is very common.  For instance, if you have a real-time program, you may want to express:

```<code>outputA = input1 && input2
</code>```

The code is straightforward to understand (because it's declarative).  However, to make it work you have to execute it in a tight loop.  You re-evaluate outputA every time through the loop.  A lot of desktop or web programmers wouldn't like this because it's inefficient.  To them, the only time you should re-evaluate outputA is when input1 or input2 changes.  They would rather see something more like you're describing:

```<code>when input1 changes
    evaluateOutputA()

when input2 changes
    evaluateOutputA()

evaluateOutputA()
    outputA = input1 && input2
</code>```

Now if this is what you want (and personally I don't prefer this idea), and your goal is efficiency, then you still have to ask yourself what the processor is doing under the hood.  Obviously there's still some kind of loop running that compares the input states to the previous input states every time, and executes the appropriate code whenever one changes.  So really it's less efficient and it's harder to read and harder to maintain.

On the other hand, if the work that you have to do when input1 changes is significant, then your when clause might make sense.  In PLCs this type of instruction is called a "rising edge detection".  It saves the state of input1 on the last time through the loop, compares it to the value this time, and executes the logic if the last state was false and this state is true.

If you don't have a Von Neumann Architecture, then the game changes.  For instance if you're programming an FPGA in VHDL, then when you write:

```<code>outputA = input1 && input2
</code>```

(... or whatever the appropriate VHDL syntax would be) then the FPGA actually gets wired up such that input1 and input2 are wired to the input of an AND gate, and the output of the AND gate is wired to outputA.  So, not only is the code easy to understand, it's also executed in parallel with all the other logic, and it's efficient.

When you're talking about an industrial controller like a PLC or PAC, programmed in one of the five IEC-61131-3 languages, the typical case is this kind of arrangement:

Read inputs and store in memory

Execute main program

Write outputs from memory to actual outputs

Go to step 1

This is built into the architecture of the system, so it's expected that you'll just write:

```<code>outputA = input1 && input2
</code>```

... and it will be executed in a continuous loop.

There are also interrupt routines in these machines.  These are more like hardware level support for the when operator that you're talking about.  The hardware interrupt is a means of executing some code on an external event.  For instance, when a network card says that it has data waiting, the processor normally has to read that data immediately or you'll run out of buffer space.  However, for the amount of times you need to hook a real hardware interrupt, I doubt including a language keyword for it is worthwhile.  You'd be limited to CPU input pins, and it looks like you want to test internal program state.

So, in a traditional language (without a tight loop that runs infinitely) you have to ask the question, "when does the evaluation code run"?

If you write:

```<code>when A do
    launchNukes()
</code>```

...and assuming A is an arbitrary boolean expression, how do you know when to re-evaluate that expression?  A naive implementation would mean you have to re-evaluate it after every single memory write.  You might think that you can narrow it down, but consider this:

```<code>when systemTime > actionTime do
    launchNukes()
</code>```

Notice that systemTime is always changing (every time you read it, you'll get a different number).  This means that the conditional part of all of your when clauses have to be re-evaluated continuously.  That's almost impossible (and just consider for a second what happens if your conditional expression has side effects!)

Conclusion

You can only have a when statement (like you're describing) in an architecture based around an infinite loop that runs the main program, then executes the when statements if the conditions went from false to true on this loop.  While this architecture is common in embedded and industrial devices, it's not common in general purpose programming languages.

Body:
What you're talking about is less syntax than structure.  You could really only have a when statement like that in a system that executes a finite amount of logic, then executes the when statements, then loops around and executes the logic again, continuing in an infinite loop.

For instance Windows programming is typically "event based".  Subscribing to a button's Click event essentially means "do this when clicked".  However, what's going on under the hood is a message processing loop.  Windows sends a message to the application when the user clicks the button, and the message processing loop in the application runs the appropriate event handler.

If you use events in, for instance, C#, you can do this without a message loop, but the limitation is that you have to declare the event ahead of time, so you can't write an artibrary when statement that watches for any kind of state.  You have to wait for a specific event.

To get this behavior in a Von Neumann Architecture you have to run some kind of infinite loop that checks for all the conditions every time through the loop running the appropriate code if appropriate.  Internally you just get a big list of if/then or switch statements.  Most desktop application and web programmers would vomit if they saw such a construct so it's really only palatable if you wrap it in some kind of syntactic sugar like the Windows event model (even though that's what's going on under the hood).

On the other hand, if you look at the field of embedded firmware development, real-time executives, or industrial controllers, this model of programming is very common.  For instance, if you have a real-time program, you may want to express:

outputA = input1 && input2

The code is straightforward to understand (because it's declarative).  However, to make it work you have to execute it in a tight loop.  You re-evaluate outputA every time through the loop.  A lot of desktop or web programmers wouldn't like this because it's inefficient.  To them, the only time you should re-evaluate outputA is when input1 or input2 changes.  They would rather see something more like you're describing:

when input1 changes
    evaluateOutputA()

when input2 changes
    evaluateOutputA()

evaluateOutputA()
    outputA = input1 && input2

Now if this is what you want (and personally I don't prefer this idea), and your goal is efficiency, then you still have to ask yourself what the processor is doing under the hood.  Obviously there's still some kind of loop running that compares the input states to the previous input states every time, and executes the appropriate code whenever one changes.  So really it's less efficient and it's harder to read and harder to maintain.

On the other hand, if the work that you have to do when input1 changes is significant, then your when clause might make sense.  In PLCs this type of instruction is called a "rising edge detection".  It saves the state of input1 on the last time through the loop, compares it to the value this time, and executes the logic if the last state was false and this state is true.

If you don't have a Von Neumann Architecture, then the game changes.  For instance if you're programming an FPGA in VHDL, then when you write:

outputA = input1 && input2

(... or whatever the appropriate VHDL syntax would be) then the FPGA actually gets wired up such that input1 and input2 are wired to the input of an AND gate, and the output of the AND gate is wired to outputA.  So, not only is the code easy to understand, it's also executed in parallel with all the other logic, and it's efficient.

When you're talking about an industrial controller like a PLC or PAC, programmed in one of the five IEC-61131-3 languages, the typical case is this kind of arrangement:

Read inputs and store in memory

Execute main program

Write outputs from memory to actual outputs

Go to step 1

This is built into the architecture of the system, so it's expected that you'll just write:

outputA = input1 && input2

... and it will be executed in a continuous loop.

There are also interrupt routines in these machines.  These are more like hardware level support for the when operator that you're talking about.  The hardware interrupt is a means of executing some code on an external event.  For instance, when a network card says that it has data waiting, the processor normally has to read that data immediately or you'll run out of buffer space.  However, for the amount of times you need to hook a real hardware interrupt, I doubt including a language keyword for it is worthwhile.  You'd be limited to CPU input pins, and it looks like you want to test internal program state.

So, in a traditional language (without a tight loop that runs infinitely) you have to ask the question, "when does the evaluation code run"?

If you write:

when A do
    launchNukes()

...and assuming A is an arbitrary boolean expression, how do you know when to re-evaluate that expression?  A naive implementation would mean you have to re-evaluate it after every single memory write.  You might think that you can narrow it down, but consider this:

when systemTime > actionTime do
    launchNukes()

Notice that systemTime is always changing (every time you read it, you'll get a different number).  This means that the conditional part of all of your when clauses have to be re-evaluated continuously.  That's almost impossible (and just consider for a second what happens if your conditional expression has side effects!)

Conclusion

You can only have a when statement (like you're describing) in an architecture based around an infinite loop that runs the main program, then executes the when statements if the conditions went from false to true on this loop.  While this architecture is common in embedded and industrial devices, it's not common in general purpose programming languages.


答:
We could have a selection of standard architectures such as Domain
  Model, Transaction Script etc, but once we choose one of these, we
  have to follow a strict architectural template.

Why stop there? Why not just write a few standard applications and have everyone use them?

Of course, you'd have to compete against companies like SAP, Oracle, IBM, CA Technologies, and Google, so you'd better know what you're doing.

There are a lot of products in the enterprise applications space, so you have to ask yourself:

Why does any enterprise bother to write its own applications?

If you can think of a good answer to that, you can probably start to see why a small number of standard architectures might not work so well. That's not to say that all enterprise applications are designed well, or that there's not commonality between many enterprise applications. However, corporations tend to compete against each other, and I suspect that building their systems the same way that their competitors build systems might not be as appealing to a corporation as you'd think.

Title: Standards in Enterprise Development

Body:
Is it perhaps time for enterprise systems to be developed to strict enforced standards? Many books list optional 'standards' and best practices, but these are purely suggested practices. Still, every time I look at the code for an enterprise system I have not been a part of, I spend a lot of time trying to work out the architecture.

Should we not have some form of ISO accreditation for our systems? We could have a selection of standard architectures such as Domain Model, Transaction Script etc, but once we choose one of these, we have to follow a strict architectural template. Systems could be audited to ensure we are working to these standards, and our companies would carry this accreditation.

This would be better for developers because when we take on legacy work that was written by another company, we will not have to spend time deciphering the architecture.

It would benefit clients because they would know that if they used the services of an accredited development company, they could used another company to maintain/amend it, and not be tied to the original developers.


答: What would be the point, you aren't going to be able to force companies to use certain standards... the point of software development is making something custom, not boilerplate. There are always trade-offs for various design decisions, one company may have a product where they care primarily about scaling while another has a similar software product where security is their primary focus. How would on standard work for both of these? Naturally they are going to spend more time on differnet areas of the software and making differnet architectural decisions based on their perceived needs.</p>

Title: Standards in Enterprise Development


答: You should look into PhoneGap and see if it will help you with porting it to iOS. You don't need a Mac to do the port because PhoneGap basically turns your app into an HTML5 app that can run on practically any device.</p>

Title: Need advice on which route I should take for porting app from Android to iOS

Body:
I have developed this android application  and I am looking to port it to iOS.

My questions are:

1) I am planning to finance the iOS development with the money earn't from the android sales which is about $200 at the moment. Would it be reasonable to get the project done for this amount even if it is outsourced to elance or odesk etc?

2) I have heard the code quality for outsourced iOS projects to be bad, I dont want any memory leaks and crashes because of overflows etc.

3) I currently dont have a full time job so I can technically do the project myself, however I dont have a apple pc or iPhone (dont really want to get them either).

I know C pretty well but I haven't really released a major C project that must be 100% stable. How many hours to learn iOs and do the port? And would it be worth my time taking into consideration that if I do enjoy it I may get into it fulltime.

4) What would the demand be like for someone that can do Android and iOS?

Thanks


问:
Do you have to be good at math to be a good programmer?
It seems that conventional wisdom suggests that good programmers are also good at math. Or that the two are somehow intrinsically linked. Many programming books I have read provide many examples that are solutions to math problems, or are somehow related to math as if these examples are what make sense to most people.

So the question I would like to float is: do you have to be good at math to be a good programmer?

答:
It does depend on what you want to do. You to need know American high school math at least. Trig, logs, etc. If you can't solve the problem "Mark can mow the lawn in 2.63 hours and Mary can mow the lawn in 1.87 hours, how long will it take to mow the lawn if Mark and Mary work together?" I don't think you could do much programming.

Also, what is math? Is converting from decimal to binary to octal to hex math? You can find calculators to do that easily.  I think a programmer should be able to convert 49 to base 7 rather quickly.

OwnerDisplayName: Charles Roper


问:
Are captchas worth the decreased usability?
When is it useful to use a captcha? When is it an unnecessary hindrance? Is a captcha just a quick fix for the lazy/unexperienced programmer, or are they really the best way to prevent spam and bots? </p>

答:
In my experience, even if you have the best captcha in the world, there are a lot of spammers who are nowadays employing real humans for very low wages to simple visit the site, signup (or whatever) and post their spam 'manually'.

So any system that requires you to differentiate between "human" and "bot" is not going to work when faced with an actual human. Whatever system you come up with is not going to be fool-proof and you're going to need to manually verify anonymous (or "near anonymous" - that is, new signup) content.

I've actually found that a pretty good system is one that requires javascript. That is, have some javascript on the page that copies a randomly-generated value into a special field in the form. On the server, verify that the value has been copied. In my experience, that's stopped a great many spammers. It's not 100%, and perhaps not as good as ReCAPTCHA, but it works well enough for the sites I've worked on, and you don't have to worry about accessibility (there are clients that don't have javascript, but they are fewer and further between these days).


答:
I think you're going to have to do it yourself. Keep in mind, that to release an iPhone app you need to be in the iPhone developer program, which I believe is $99/yr.  So you really have $101 to work with.  And you'll probably want an actual iPhone (or iPod Touch) to test the program(s).

My business advice would be to focus some more on android development.  Extend this app, make some new ones.  Generate some more revenue, and then re-visit the idea of iOS ports in a few months with a bigger bank account.


问:
C++ XML Parsing: Suggestions on Approach for Parsing and Storing data
I am looking into developing a C++ application to parse xml (using the rapidxml framework), and I would like some advice on how to approach this.

The file I want to parse is a XML game file that defines a set of addons for a starship ('outfits'), which have several attributes in common (like name and cost), but also fall into various categories.

For example:
Fixed weapons: range, rate of fire

Turret weapons, range, rate of fire, turret slew speed

Afterburners: acceleration modifier, fuel burn speed

etc etc etc

There are at least 5 classifications of outfits (and say 3 or 4 outfits that fall into each category), and some, like the weapons, have a few attributes in common with each other, but not with other categories like afterburners.

I want to write parsing code to handle each type of object and store its data in objects. I also want to minimize how much code I have to retype (i.e. make use of good OOP style so I can add new categories or tweak existing ones in the future).

What is the best way to approach this? I have already started the program, but I would like to have some input on the best approach.

Since this is a really broad question, I will give you some of my thoughts/specific questions so you can see what I am looking for:

Should I have a basic class called 'outfit' and use inheritance to customize the parsing for each specific category (i.e. 'fixed-weapons')? Should I have multiple levels of inheritance for similar categories (i.e. 'weapons'). How can I minimize code retyping so I only have to write the specific routines for each category?

Where should I handle the errors: in 'outfit', or in the derived classes? How much error handling do I need?

How can I easily access these objects later? Should I make a list-object with a vector containing each object? How can I access each object by name?

Any input is appreciated; you don't have to give a complete and comprehensive rundown on how to do this (though that would be nice :P).

答:
Try first writing the code or pseudo code that uses and manipulates the objects in the main body of the game.  This may provide insights into what the object hierarchy should look like.  It will at least validate your list+vector storage approach.

Deep class hierarchies are out of fashion - your app may be the exception but look at composing object with helper classes to reduce repetition of code.

Think about the builder pattern, where objects of another class are responsible for the XML parsing and return the main object fully formed.  This will reduce the complexity of your main classes and be helpful if the storage format changes.


问:
Data acquisition, storage and management
I have a device that can measure different values over time, one sample per second. After one measurement run I can export the data in form of a CSV-file. One row per second with timestamp and about 20 columns (values).

The question now is how to store these data masses to make the data accessable. I want to work with it using Matlab. I have for example 50 files of data, each representing one measurement run. Each containing around 120 tsd. samples of 20 values of type float, for example a temperature.

It would be great if I could request all samples at the same temperature for example.

So actually I am looking for a software that can handle and organize that data or a hint how (and what kind of) database to build.

Thank you for your help!

答:
If you know the exact questions you want to ask from data and response time is not a big deal, you can use a program (written in any language of your choice) to go through the data prepare summaries every given interval so that the data volume becomes manageable, then load the summaries into a free database like MySQL where you could use SQL to get the results or you could load the summaries into Excel if the volume is small.

Short of that, if you need to store every data record without aggregation or summaries, you will need to have a process to load the data (possibly in batches based on time) into a database (SQL Server, Oracle, MySql, FoxPro, etc.). The process might be built via a database utility or an ETL tool.

The choice depends on how much money you want to spend, and on the level of expertise you have with the chosen tool.

There are applications that can process very large data in memory and produce good statistical information. OLAP tools can do some or all of the above in addition to data presentation. (see for example:(Link-1 ) or (R-Link).

The processes involved in satisfying your requirement are covered in the areas of ETL, OLAP, Data Marts and Data Warehousing as well as Dashboards.


答:
Exceptions are simply an error detection mechanism. By themselves they are of no use.

But by detecting an error, they allow to trigger fault tolerance mechanisms in order to recover from the erroneous state by switching to an error-free state (a previous state or a new one). That way, the error is not propagated to other parts of the system.

Title: Do exceptions basically exist to prevent a system from crashing?

Body:
Second of all, I was wondering if anyone knew what the difference was between exceptions (in the realm of exception control flow) and Exceptions (such as used in Java).

But are they there to basically protect the system from crashing by terminating the user program?


答:
MRTG may offer something for you if you are bothered about generic behaviour and not specific behaviour as time goes backwards.  Although it is a way to consolidate data and not to store it precisely. </p>

<p>If you have only specific question you know ahead of time, then you can pre-parse your data.  If not, you need to either have some database or load the whole data in memory and deal with it that way.  </p>

Title: Data acquisition, storage and management

Body:
I have a device that can measure different values over time, one sample per second. After one measurement run I can export the data in form of a CSV-file. One row per second with timestamp and about 20 columns (values).

The question now is how to store these data masses to make the data accessable. I want to work with it using Matlab. I have for example 50 files of data, each representing one measurement run. Each containing around 120 tsd. samples of 20 values of type float, for example a temperature.

It would be great if I could request all samples at the same temperature for example.

So actually I am looking for a software that can handle and organize that data or a hint how (and what kind of) database to build.

Thank you for your help!

Body:
MRTG may offer something for you if you are bothered about generic behaviour and not specific behaviour as time goes backwards.  Although it is a way to consolidate data and not to store it precisely.

If you have only specific question you know ahead of time, then you can pre-parse your data.  If not, you need to either have some database or load the whole data in memory and deal with it that way.


问:
Should a development machine be inside a VM?
This post by Rob Conery (note the slug) says that development environment should be run inside a virtual machine. I see what he's saying and tend to agree, but still feel a little uneasy. Now that virtualization is so mature that even production systems run inside VMs speed is pretty much a non-issue, but as I say something bothers me here.

What's your take on virtualizing your development machine? Have you already done so? If you did, any pitfalls or gotchas along the road?

答:
I have used VMs for development and by and large it is not tremendously different from developing on my own machine. If you're using Source Control properly there aren't many differences.

The main differences are that if you are offline for any reason you don't have a development machine available to you, so not so great if you travel or work from home a lot. Also I never figured out how to run multiple monitors on Remote Desktop, but I'm sure that is my failing rather than a problem with the principle. I usually used my main monitor for development and kept the second one for my desktop machine with email, browsers and so on running.

I'll add that if you're working in a way where you need to check your code works on different platforms - particularly stuff like developing installers - then being able to run up VMs for different OS versions is amazingly handy.


答:
My experience with developing on VMs in a corporate environment is that due to virtualisation of multiple cores being fraught with difficulties, it's difficult to get the kind of performance that many enterprise development machines need.

Getting the code-compile-test inner loop to be as fast as possible requires the best machines possible - compilation and the running of tests obviously run faster on machines with more cores, as those activities can be quite easily be executed in a concurrent manner*.

Until mainstream development OSs can deal with the number of available cores being volatile, and until virtualisation software can intelligently offer some kind of "up to N core" contract, virtualised development machines will not offer the same kind of productivity returns as physical devices.

EDIT: This just recounts my personal feelings on developing using corporate-dictated VMs, which are often proscribed to cut hardware costs, which tend to run on servers. Running a local VM seems mostly superfluous provided you're enforcing good source control discipline, unless your project specifically requires you to develop code for multiple OSs.

*:by which I mean the subtasks inside the compile stages and test stages can be run concurrently, NOT compiling and testing concurrently :)

Title: Should a development machine be inside a VM?

Body:
This post by Rob Conery (note the slug) says that development environment should be run inside a virtual machine. I see what he's saying and tend to agree, but still feel a little uneasy. Now that virtualization is so mature that even production systems run inside VMs speed is pretty much a non-issue, but as I say something bothers me here.

What's your take on virtualizing your development machine? Have you already done so? If you did, any pitfalls or gotchas along the road?


答:
As usual: it depends. For example, I certainly wouldn't recommend it for any real-time or computer game-related development.

My personal experience: I have a late-2009 iMac, and I found that Visual Studio 2010 is basically unusable in Parallels Desktop, to the point that pressing a key in the code editor takes a matter of seconds to register. Windows in SQL Server Management Studio would defocus and switch focus apparently at random. I just ended up going with boot camp.

Of course, a new project of mine will involve an iOS application with a Windows-based configuration tool, so it may be too painful to not use virtualisation, but if desktop virtualisation technology hasn't moved along enough in the last year or so, I'll probably just set up another desktop here.

When it comes to testing a server application, that's a different situation, I'm perfectly happy to virtualise that, but I need responsiveness in my development applications.


答:
Patience

Joining a new company can be quite daunting, especially if you have a new product to learn, and use different tools to what you are used to. Give them time to settle to the new environment and get up to speed. Assign them tasks to do, but be aware it will take them much longer than a normal experienced programmer will take.

Support

You don't necessarily have to assign a dedicated mentor to them, but be sure there are plenty of people around who can offer them help when they need it.

Everyone has different ways of learning, some might find they need a mentor, others may find a mentor slows them down. There is no one size fits all solution, so instead let them find their ground and support them, and be patient as they learn the ropes.

Title: How can I make the life of a new hire comfortable?

Body:
As a senior member of a software team that, unfortunately, has little documentation for legacy reasons, what are the things that one could do to make a new hire comfortable?

I have been planning debug sessions with the person on specific defects/feature requests to get him/her acquainted with the code base. However the code base is real large, and its only a fixed amount of code I can expose the person to in this manner.

I am looking for suggestions in either cases when the new hire is a recent graduate or an experienced professional.


问:
Is the time spent customizing your dev machine environment worth it?
There are times when I am working on programming project and I get the itch to change some stuff in my environment (OSX or Linux). Vim might not being doing exactly
what I want, so instead of doing it the round about way I've been doing for a
couple months (sometimes years) I go and figure out the right way. Or I may be
doing something long handed in bash and I say to myself why don't I figure out
a better way.

The thing is when I go off and do this hours can fly by. Sometimes I
get stuck on trying to get what I want. I'll know I'm really close, so I don't give
up. I usually always get it eventually, but its after hours of tinkering and
googling. I hate the feeling of giving up and having to deal with something I
know could work better.

When I'm done I have a warm feeling knowing that my environment is a little more smooth
and personalized, but I wonder could my time be better spent. Where do I draw
the line? It seems with the all the UNIX-style tools there is an endless amount
to learn.

Always thought the sign of a superior programmer is someone who goes out of
their way to make the computer bend to their will. Am I doing it right? I figure
the bash shell, unix/linux, and vim will be around forever, so I see it as an investment.

But then again I just spend 3 hours trying to get some stupid thing the vimperator firefox
plugin to work right.

So I wondering what this community think about this.

答:
Certainly, spend some time tweaking things to your liking.  If you don't, you'll have to put up with poorly chosen defaults or inefficient tools over and over and over, day after day for all year and next year.   </p>

<p>Avoid spending too much time on it by doing so only after 4pm,  supposing the ol' factory whistle blows at 5pm.  Unless you're really gonzo nuts about your work, going home will always be appealing so your enviro tweaking will be limited to one hour or whatever time was left.   </p>

Body:
Certainly, spend some time tweaking things to your liking.  If you don't, you'll have to put up with poorly chosen defaults or inefficient tools over and over and over, day after day for all year and next year.

Avoid spending too much time on it by doing so only after 4pm,  supposing the ol' factory whistle blows at 5pm.  Unless you're really gonzo nuts about your work, going home will always be appealing so your enviro tweaking will be limited to one hour or whatever time was left.


答:
I started at a new job 4 months ago, and I really think that my new workplace did a really good job on this new hire stuff.

A. Buddy

They have a so-called "buddy-program", where developers can sign up to be a buddy / mentor for new employees. When a new developer is hired, a developer in the same team (who signed up to be a buddy) is pointed out to be the new guy's buddy / mentor. It is his responsibility to get the new guy up and running, help him out with the problems he will encounter, go to lunch with him, introduce him to the team and so on.

B. Low dependency

This was previously mentioned also, but start out with assignments that are not critical and too hard to do, without full knowledge of the code-base. There is nothing worse than getting thrown into a code-base you don't know, and then need to perform from day 1. If possible, make assignments that are relatively easy AND span across the entire system. That way he will get some knowledge of the system.

You probably have small tasks that you didn't have the time to do, when you first wrote the code. Give those tasks to him.

C. New-hire trainings

This is probably luxury to most, but I work in a large corporation that can afford to do this. Every month or every two months or so, some kind of new-hire training are arranged. It is basically a series of presentations, with the goal of giving the new-hires some kind of knowledge about the system, how testing is done, how the bug-tracking works and so on.

Where I work, there is a lot of different teams, working on completely different tasks, but on the same piece of software. A member of each team is assigned to do a presentation on their part of the software, where they give an introduction to what that part does, how it works and so on. Besides that there are trainings on tests (I am working as a tester) about how tests are written, how they are run, how they are checked into the codebase and so on.

To sum it up, be gentle on new-hires and don't expect serious work from them in the first month or so. Give them tools to get help and if possible, give them some presentations or videos.


答:
In our company we are now using the VM for development and testing. Although there are some drawbacks for using VM's their benefits significantly outweighs them.

Before we started using VMs we had problems with setting up development machines for new developers. The first task for new developer in the team was usually to set up his own development machine.  We are a small company and we don't have always the manpower to help a new team members to set up their machine. This led to different problems: sometimes the bug was reproducible only on their machine or they couldn't reproduce it at all, the application could not build properly etc.
Also there was also a problem that some of our senior developers were working on multiple projects on working environments that were not always compatible.

When we switched to VMs, everything changed. Now only one person is responsible for setting up the environment in a VM with everything that is related to the project. When he's finished all team members are provided with the copy of the VM. This reduces the time for setting up the environment for every new team member (copying the VM should not take more than 1h). It also allows us to work on multiple working environments in parallel.

The drawbacks for using VMs: speed. The performance hit on the VM is visible. On slower workstations it can make development nearly impossible. If you have a good workstation (quad core, 8+GB RAM, SSD) you probably won't notice it.

ContentLicense: CC BY-SA 4.0


答:
I would like to add that certain types of development are much more difficult (if not impossible) through virtualized machines.

I happen to work at a company where we offer software packages that integrate with a number of different USB peripheral devices (Eg. webcams, label printers, magnetic stripe readers, etc...).  Even if I were to map USB ports to a virtualized server I have noticed bizarre and inexplicable problems with the third party vendor device drivers.

Like I said, I don't think this situation warrants NOT working on virutalized development machines, however it is one that we haven't figured out yet, thus we maintain physical workstations for different environments in a lab.


答:
It is a feature of dataflow languages such as hardware description languages (Verilog and VHDL).

Other than that, I can think of Ada and its exception handling mechanism: An exception handler is triggered when some exception is raised.


答:
It sounds like you're looking for condition variables, things that allow threads to sleep until some predicate becomes true.

Boost implements them for C++, the Apache Portable Runtime implements them for C. In Common Lisp you'd use bordeaux-thread's make-condition-variable.


问:
How is oData different from a REST service?
I am looking into writing a web service API and I am thinking of creating a REST service. What does OData means in this context? Can you please explain the difference between OData and REST? </p>

答: OData is a standard implimented using REST. </p>


答:
As others have mentioned it depends on several things:

What does your environment look like?

Do you have sufficient access rights to do development?

Is your HW up to snuff?

Environment

Using a VM can help if you are working on multiple versions of a project; multiple projects; or targeting a different OS from the one you normally run (host OS).  I do a lot of SharePoint work and being able to run a different machine for the various versions of a release is helpful since I can just start a different machine and have a good feel for the state of the GAC / database.  Also if you need to target a *nix application environment but have a Windows machine then you can still do development in a VM (this is how I'm learning Ruby at home even though I generally do .NET dev work).  I generally advocate when doing ASP.NET development testing/developing on the same version of IIS that the app will ultimately run under (this same rational applies to other server target environments).  Depending on the version of OS there may be some small but critical differences.  Note this doesn't imply you should code to a specific version of IIS / OS but let's be honest it really, really has to work where you're going to deploy it not just on your local machine.

VM's also (depending of the software used) allow you to take snapshots of the current machine state and / or clone them.  This can be invaluable when prototyping something and you don't have to be as concerned about what is happening in your GAC / Registry / etc.  I've also found them very valuable in setting up for a client demo ahead of time.  Because the demo environment was in a VM I could continue working right up to the point of showing the client what we had completed because I was working in a different machine.

Sufficient rights

This generally applies to people that work for a company with a rather uptight set of policies for access rights.  If you are unable to have unfettered admin on your machine this would be a good time to work in a VM.  Typically the powers are only worried about locking down your host OS, the guest can be wide open (permissions wise).  I have run into weird problems with roaming profiles, crippled admin rights, and running VS 2010; using a VM allowed me to avoid these problems.

Is your HW up to snuff?

This boils down to either your VM images are on a server and your remote into them OR you run them locally.  If you are running on the server then the biggest concern is probably going to be are there too many VM's running on the same hardware.  Locally you basically want plenty of RAM and to minimize how often you overload the R/W buffer for your hard drive.  For basic LOB / SharePoint / ASP.NET development I've found that a minimum of 8 GB of RAM and a dual hard drive configuration works just fine in practice (running an i5 but I've worked with a Core 2 as well).  The second hard drive makes the biggest difference in performance.

Note: I don't have any stats to back this up but I've noticed that Virtual PC has a tendency to underperform compared to both VMWare and Virtual Box.  I can't speak to Hyper-V since I haven't worked with it.  I wouldn't be surprised if using Virtual PC (as an initial foray into using VM's) jaded developer's on using virtualization software.


答:
I do all my personal development in VMs. I have several VMs setup for different environments and it works fine.

I have a dell studio 15 laptop (quad I7 2.8ghz, 8gb ram, ati graphics) running win 7 ultimate 64bit with virtualbox installed on. I have all my VMs running off an external 500gb usb drive velcroed to the laptop.

VM 0 - Win 7 64bit clean install as base template

VM 1 - Win 7 64bit (2 cpu, 4gb ram, 120gb hd) with Visual Studio 2008 toolset

VM 2 - Win 7 64bit (2 cpu, 4gb ram, 120gb hd) with Visual Studio 2010 toolset

VM 3 - Win 7 64bit (2 cpu, 2gb ram, 120gb hd) with Eclipse Java toolset

Unless I'm doing something that requires very high IO, I have felt that performance is good and I wouldn't know I'm inside a VM if someone had just handed me the laptop and said start developing.


问:
What personal process can I employ at a non-software based company?
What is the best way for a developer to track his/her hours at work, if no framework exists at that firm which would avoid any complications with internal classified information being stored on a server I own at home? In particular, I would like to hear of any methodologies or software that could be used in this situation with limited issue.

I just graduated from college, and am moving into my first full-time job with an embedded systems firm, which doesn't seem to have any particular process set up for its employees to use. Since last summer, I've been working on improving my development process, trying to record my time usage, bugs found, and other simple metrics for my process. Until now, I have been using Microsoft Team Foundation Server (TFS) to do this from one of my personal servers, and have enjoyed working with it. The firm I am going to, however, doesn't seem to have anything similar, so I am stuck with needing to find a way to continue tracking these metrics. I feel I should not use my TFS server (or a similar tactic, such as Traq), since there would be the chance of exposing company secrets to the outside world through my server.

答: Time tracking software really helps a lot in managing productive time efficiently. But in order to track time successfully you will need self discipline, right tools to use and resources. I find this article that discusses some good alternatives in time tracking that can also help you decide what would be the best tools for you to use.</p>


答: REST is an architecture for how to send messages back and forth from a client to server using HTTP.  OData is a standard championed by Microsoft that uses a REST architecture to send particular types of messages over HTTP.  OData talks about what the messages look like (the content).  REST is the architecture of how those messages get sent back and forth.

Title: How is oData different from a REST service?

Body: I am looking into writing a web service API and I am thinking of creating a REST service. What does OData means in this context? Can you please explain the difference between OData and REST? </p>


问:
Is there any comercial application written in Visual Basic .NET?
In my work the language used to write applications is Visual Basic .NET.

I read on internet and almost all the examples and questions are about C#.

Is there any comercial application written in Visual Basic .NET? Is there any field for a VB Net developer?

答:
There are plenty actually. I don't know why, but some companies chose VB.net over C#, probably because they used to be VB shops, possibly because they feel VB.net is a better language (!)

I know of a very large design suite that is used for oil platform and ship building that has a large part written in vb.net.
I know nearly all the health system software for the UK NHS is written in VB.NET now.

The difference between C# and VB is tiny, VB has a few really cool features in there that makes it a better language that C# all in all, it's just that most people don't like its syntax.


答:
VB.net and C# compile to the same CLR so the difference between them is quite small (some data structures etc)

For commercial applications as gbjbaanb mentioned, the NHS uses a lot of VB applications and this is also true across most of the UK public sector.

Body:
In my work the language used to write applications is Visual Basic .NET.

I read on internet and almost all the examples and questions are about C#.

Is there any comercial application written in Visual Basic .NET? Is there any field for a VB Net developer?


问:
Are there restrictions on table and column names in DB2?
I'm working with a DB2 database and I can't help but notice - these table and column names are really confusing!

I realize that good names are important in every facet of software development, and it's quite possible that the non-intuitive names are unique to my experience, but someone told me that DB2 places severe restrictions on table and column names.

Is this true?

Or could it be that DB2 admins have traditionally followed a certain naming convention that seems foreign to SQL Server veterans like myself?

答:
Back in the old days of DB2 on AS/400 there was a limit to the name of the table.  It was pretty short too, when I worked with one of these systems as an application developer it was a real pain.

However, it has been many years (possibly as many as 10) since this has been a contraint, and as far as I know it's not a contraint for DB2 on AIX either.

If these are tables being setup for your application and they are designing the tables ask that they use your names and column names.  If you are accessing legacy systems or systems outside your control, it will be more of a challenge.  I think they should be able to setup aliases at a minimum and if my memory is correct of AS/400 those aliases can be applied to column names as well.

In my case I also sat on the standards committee for IT and at the time everything in IT centered around the AS/400 platform and the standards reflected that.  We were changing even then (2003 timeframe) to get away from these cryptic names though.

Good luck to you.


问:
What are the legal considerations when forking a BSD-licensed project?
I'm interested in forking a project released under a two-clause BSD license:

Copyright (c) 2010 {copyright holder}
  All rights reserved.

Redistribution and use in source and binary forms, with or
  without modification, are permitted provided that the following
  conditions are met:

(1) Redistributions of source code must retain
  the above copyright notice, this list of conditions and the disclaimer
  at the end. Redistributions in binary form must reproduce the above
  copyright notice, this list of conditions and the following disclaimer
  in the documentation and/or other materials provided with the
  distribution.

(2) Neither the name of {copyright holder} nor the names of its
  contributors may be used to endorse or promote products derived from
  this  software without specific prior written permission.

DISCLAIMER

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

I've never forked a project before, but this project is very similar to something that I need/want. However, I'm not sure how far I'll get, so my plan is to pull the latest from their repository and start working. Maybe, eventually, I'll get it to where I want it, and be able to release it. Is this the right approach?

How, exactly, does this impact forking of the project? How do I track who owns what components or sections (what's copyright me, what's copyright the original creators, once I start stomping over their code base)? Can I fork this project? What must I do prior to releasing, and when/if I decide to release the software derived from this BSD-licensed work?

答:
Clearly people are misunderstanding what I said so here is a re-phrase:  I am not giving you legal advise.  If that is what you want please seek legal advise from a lawyer and not from this site.  That said, what follows is my understanding of forking a project:

In general, as I understand it, you must leave the comments and not claim that any code they wrote is yours.  I would create new files for your code and try not to touch theirs -- unless to extend and bug fix.  I would contact the other developers before you fork and see if your contributions can be added to the main code.  If not, then fork and re-name but keep notices and attribute credit where credit is due.


答:
There certainly are jobs out there for VB.NET developers. I interviewed with two companies just last year that use VB in their commercial applications. One is a major healthcare  IT provider that uses it almost exclusively although they are slowly migrating to C#. The other is a company that develops software for nonprofits, using VB in some of their web applications.

So it's not as popular as C#, and it may be a shrinking field, but you can still find jobs out there.

Title: Is there any comercial application written in Visual Basic .NET?


问:
Is the agile approach too much of a convenient excuse for cowboys
I believe that an agile approach is best for projects where the requirements are fuzzy and a lot of interaction is required to help shape the end user's ideas.

However... In my professional work, I keep ending up at companies where an "agile" approach is used as an excuse as to why no effort was put into an up front design; when the requirements are well understood.

I can't help but thinking that if the agile approach wasn't around, I'd be sitting here with a nice high-level specification and not having to revisit the same screen and functionality every second day when something else crops up or so and so hadn't thought of that.

Are the benefits of agile methodologies really enough to outweigh the excuse for being lame it gives to cowboy technical leads?

Update: Ironically I'm now a certified Scrum Master. One of the papers presented on the Scrum course observed that the best development process was one where there was a single expert or guru making the design decisions, however that has obvious weaknesses. Scrum shifts the responsibility for producing quality software to the "Team" which means a sub-standard team can get away with churning out spaghetti which I guess is no different to other Agile and non-Agile development processes.

答:
I'm currently working in a shop where this is the case, except it's more to do with organisational culture than with particular individual cowboys.

The organisation has always operated on a relatively loose, "informal Agile" approach. I wouldn't say it's truly Agile, it's more "Agile in name", but just plain non-existent methodology in practice. Different teams operate differently, but since the overall organisational culture doesn't have any methodology in place other than a very loose "Agile in name only" process - it's relatively cowboyish and chaotic overall - especially in intergration (and there is a lot of that).

The moral of the story is - Yes, this does happen. If I was job hunting at the moment, I would be very careful with this. If a shop is claiming to be Agile - I'd ask some pretty tough questions in the interview to ensure that more than just a misnomer of Agile is actually being followed.


问:
The relation between Business Rules Engines and Constraint Programming languages
If one looks at (perhaps older) manuals of Drools or some other rule engines,
one of the illustrations of their added value is solving puzzles such
as the Miss Manners puzzle (listed in the Drools Documentation). Now, such puzzles are naturally formulated
and solved using Prolog or the more recent Constraint Programming languages, and
one wonders why would anyone use Drools for this purpose. The added value
which Prolog and CPL give in this case is their ability to naturally
formulate the puzzle as a set of logical predicates and to automatically
search the space of solutions (with CPL being more efficient in this respect).
But what is the added value of product such as Drools (I mean besides of
the bells and whistles of taking, for example, an Excel file and translating
it into a set of rules)?

More specifically, Prolog implements backtrack search, CLP implements backtrack search
with constraint propagation, and therefore instead of searching, so to speak, the
whole Cartesian product of spaces for individual variables, they prune away large portions
of this product space. This is what makes them effective and useful. Both Prolog and
CLP are discussed amply in the literature.

On the other hand, while it is clear that Rete algorithm caches the set of rules
in the form of some data structure(s), thus (to my understanding) making it more
effective to evaluate the output if some of the inputs have changed, and giving
means to effectively update this data structure for incremental changes, it is
difficult (for me) to understand the basic idea, and even more so, its effectiveness (compared to what? to Prolog? to CLP)? Unfortunately, it is hard to find good
references that view Rete algorithm in this wider context.

The documentation of Drools is unfortunately not very informative in this respect.
The most I could find was "The Rete algorithm, Leaps algorithm, and its descendants such as Drools' Reteoo (and Leaps), provide very efficient ways of matching rule patterns to your domain object data. These are especially efficient when you have datasets that do not change entirely (as the rule engine can remember past matches). These algorithms are battle-proven". Very efficient - compared to what? Battle proven - could one point to real-world
applications?

I would appreciate it if one could throw some more light on this subject or give a valid
reference.

答:
I think the argument for many commercial Business Rules Systems using forward chaining engines
(eg. Drools) vs backward chaining (Prolog) is that many "Joe programmers"
are used to dealing with IF/THEN/ELSE logic - and this makes it a whole lot
easier to market to the masses. I don't think technical merit
has anything to do with it.

I'm posting this as community wiki because it is my rather coloured opinion and
not a real answer.

OwnerDisplayName: John Donn

OwnerDisplayName: NealB


问:
Difference between Idiom and Design Pattern?
What is the difference between idiom and design-pattern? It seems that these terminologies overlap somewhere; where exactly, I don't know.  Are they interchangeable? When should I use what?

Here is a list of C++ Idioms. Can I call them design patterns?

Wikipedia defines,

Programming Idiom as a low-level Design Pattern

What does it mean? What does "low-level" mean here?

This question is inspired from another question : https://stackoverflow.com/questions/7343531/are-the-some-design-patterns-language-dependent

答:
I found this post searching for common C++ idioms, as I have been getting fairly deep into it recently and would like my code to not look as amateurish as I feel it is... :-P

Having spent quite a bit of time with Perl, I've found idioms in that language to be much like those found in natural languages, like English or Spanish (only two I know well enough to know some idioms).

I disagree that an idiom is like a "small design pattern". I still disagree, although less so, that an idiom is a way to work around a deficiency in a language.

Perhaps Luc Danton's answer comes closest, but let me explain. I think that an idiom is, well, idiomatic of those who use the language. Usually, a common expression or sequence of expressions that, while perhaps not obvious, performs an operation or expresses intent in a way that makes sense to those who are fluent enough to have seen it before.

Back to Perl, perhaps the best-known idiom is the "Schwartzian Transform", an expression that performs a sort on data in a compact and efficient manner. It is not the most obvious way to perform such an operation, but it is succinct and those who have seen it before know instantly what it is doing.

Another notable example is "The Orcish Maneuver", which takes advantage of perl's notions of true/false, rich operators, and operator precedence.

One that I personally like quite a bit is somewhat related to the Orcish Maneuver, but I know of no name for it:

```<code>push @{ $some_hash{$key} ||= [] }, $some_value;
</code>```

This is indeed not obfuscation, but rather a clear, compact expression of something that would otherwise take several lines to do. If the key is present in the hash and has a true value, de-reference it as an array and push $some_value onto that array. If the hash element is not present or has a false value, assign it an empty array, then dereference that array and do the push.

It's also worth noting that as of Perl 5.14, part of this idiom is obsolete - push can now operate directly on the array reference, no @{} needed! Also, as of Perl 5.10, one can use //= instead of ||= which checks not for truth but for defined-ness.

OwnerDisplayName: Nawaz

Body:
I found this post searching for common C++ idioms, as I have been getting fairly deep into it recently and would like my code to not look as amateurish as I feel it is... :-P

Having spent quite a bit of time with Perl, I've found idioms in that language to be much like those found in natural languages, like English or Spanish (only two I know well enough to know some idioms).

I disagree that an idiom is like a "small design pattern". I still disagree, although less so, that an idiom is a way to work around a deficiency in a language.

Perhaps Luc Danton's answer comes closest, but let me explain. I think that an idiom is, well, idiomatic of those who use the language. Usually, a common expression or sequence of expressions that, while perhaps not obvious, performs an operation or expresses intent in a way that makes sense to those who are fluent enough to have seen it before.

Back to Perl, perhaps the best-known idiom is the "Schwartzian Transform", an expression that performs a sort on data in a compact and efficient manner. It is not the most obvious way to perform such an operation, but it is succinct and those who have seen it before know instantly what it is doing.

Another notable example is "The Orcish Maneuver", which takes advantage of perl's notions of true/false, rich operators, and operator precedence.

One that I personally like quite a bit is somewhat related to the Orcish Maneuver, but I know of no name for it:

push @{ $some_hash{$key} ||= [] }, $some_value;

This is indeed not obfuscation, but rather a clear, compact expression of something that would otherwise take several lines to do. If the key is present in the hash and has a true value, de-reference it as an array and push $some_value onto that array. If the hash element is not present or has a false value, assign it an empty array, then dereference that array and do the push.

It's also worth noting that as of Perl 5.14, part of this idiom is obsolete - push can now operate directly on the array reference, no @{} needed! Also, as of Perl 5.10, one can use //= instead of ||= which checks not for truth but for defined-ness.


答:
I've worked on two vertical market desktop applications that were written in VB.NET. They had a user base of between 2000-3000 users each. One of these was in the healthcare filed and, from what I've seen, VB.NET remains a popular choice in this area.

I've also worked on a number of internal corporate VB.NET applications, both desktop and ASP.NET based. Jobs are out there but C# is more popular.