问:
Does software reuse preclude process repeatability

Code Reuse as a Problem

I was thinking about this question on software delivery, and I kept coming back to the issue of repeatability and / or reproducibility.  They matter, because if you don’t repeat a project then it becomes more difficult to improve the process you used to build the project.  Engineering involves constantly improving the processes involved with design and construction in order to produce higher quality projects.

Software can rely heavily upon reuse due to its digital form.  Instead of rewriting a module, we just call it again or copy it to the other system.  Some examples are authentication / login or perhaps a logging function.  There are many well known examples for those categories, and conventional wisdom is to reuse what exists instead of rolling your own.

Some Comparisons to Other Disciplines

Construction

In contrast, construction of physical systems (buildings, bridges) is nowhere near as reusable.  It’s true that the blueprint of a house can be reused many times to build the same copy of the house, but the construction must be performed each time.  Cut & paste doesn’t work like that in the analog world.  Bridge blueprints are less reusable that houses because site conditions will vary.

Master builders are experts recognized for having designed and / or built tens, hundreds, or thousands of things in their area.  For example, Frank Lloyd Wright, a world renowned architect and designer designed more than 1,000 structures and completed 532 works.  Contrast that with Anders Hejlsberg who has designed “just” five languages (Turbo Pascal; Delphi; J++; C#; Typescript).  In many ways, it’s an unfair comparison because the domains are different.  But at a broad level, the quantifiable production from two very intelligent people is vastly different.

Martial Arts

Martial artists will say that mastery of a move comes only from thousands of repetitions. After a good portion of those repetitions have been put in, many martial artists are surprised at how a previously perceived to be complex kata or form has become simple. Instructors of those students will also notice how the motion becomes more fluid and purposeful as well as having an economy of motion. Likewise, experienced martial artists are able to pick up more complex katas more quickly than less experienced students. Experience from repetition has given them a framework or process that allows them to learn more quickly.

Woodworking

Woodworkers experience a similar transformation. Hobbyist woodworkers always refer back to their first project that required a lot of drawers. If they complete the project, they gain a new appreciation for the efficiencies that assembly lines produce. There are other benefits such as a better understanding of how to lay out the drawers parts on the sheet stock in order to maximize use of the wood. Compared to hobbyists, professional woodworkers are able to more quickly design, start, and construct items that they have made many times before. They also gain an ability to see inherent issues within someone else's design having made that mistake in their work.

So, does software reuse prevent software developers from becoming more proficient?

In many ways, software design and construction is always new.  We don’t repeat past works, because if we can reuse a module, library, or system then we do.  We’ll preferentially extend an existing system before rewriting the entire thing from scratch.  But repetition is what allows us to find efficiency in the design and the construction. Anyone who has practiced a sport or physical activity will tell you that repetition is the key to becoming a good practitioner.

My question: Does software’s ability to be reused prevent the necessary process improvement and efficiency that comes from repeating a project?

答:
Software is different than most other disciplines, so the economics of where we best spend our time is often different.

In construction, you spend a certain amount of time and money on a blueprint (and software is far more like producing a blueprint than like building a building), then, roughly speaking, a whole lot more on actually building it one or more times.  So it is worth it to put quite a lot of work into getting the blueprint right.  More specifically to your question - it's worth repeating the effort of doing it over from scratch to make the end product a little better.

In software, when you have the blueprint, it is much cheaper to build the product than it was to make the blueprint.  At least most of the time - if the software will be embedded in a pacemaker you are much closer to the situation of a bridge builder in some ways.  But in general, reusing software might save 90% of the cost of your biggest budget item, vs. saving 90% of a much smaller budget item for building a bridge.  So, re-use wins a lot more often.

As far as productivity - when you build, say, a bridge, you face really significant real world constraints.  Imagine if architects were paid large sums of money to design bridges for massive multiplayer online games, where construction costs were near 0 and limitation significant less than the real world.  They would design bridges that are freakishly complex by real-world bridge standards.  The blueprint phase might take a little longer.

Also, there are a limited number of bridges to build, and, since design is a smallish part of the cost, you can pay for the best, and a few of the best can do most of the design.  There are hundreds of thousands of software developers, and basically all of them have a giant backlog of things they would do if they had time.  You aren't going to find one guy who does a massive portion of all that - it's kind of surprising that there are people who sort of come close, really.

Your real point seems to be that we may be losing something by re-using instead of trying to repeat and improve things.  I think you have a point.  The problem is that though it would most likely be more globally efficient to rewrite some of the foundational stuff and try to improve it, whoever takes that on gets all the risk and probably not that much of the reward.  (There is also a huge practical problem of dependency hell, which probably takes some of the win out of rewriting things, but not to the point that it wouldn't be worthwhile, at least looking at the global picture.  Copyright and patents also may force a proposed re-engineering effort bite off quite a bit of rewrite work to redo smaller pieces of existing code).

In terms of learning from repetition - in all disciplines this happens less in design than in construction, because there is less repetition, so less chance to learn, and perhaps less benefit.  Also, the process of design probably just isn't that repeatable.  It's a bit like having a process for writing a novel.  A good process can almost certainly help, and software is generally far more collaborative than a novel, but repeating a process when the goal is to invent something new is problematic.  Even novelists learn from the past, very much so, but a repeatable process is a secondary factor for creative endeavors.  And if any part of software development is really truly repeatable, why isn't a computer doing it?


答:
As pointed out in the accepted answer in another Programmers question, analogies with construction are to be taken with care:

a recommended reading for this is The Software Construction Analogy is Broken

software is often likened to construction. Unfortunately this analogy is flawed and lessons learned from the construction industry are suspect...

What I observed is, good software projects "shift" a lot of repeatability into quality assurance.

When I was a tester in 1,5 year long project, we run test cycles at weekly "checkpoint" releases, about 70 times total through the project. That was... quite repeatable, softly speaking (not much things change in a week). Testing nightly builds has been, naturally, even more repeatable - about 500 times through the project (few entertaining showstopper bugs were too rare to make a difference).

Now, following that "suspect" analogy, tell me a construction company that has built 500 bridges - all with the same team.

Following it further, tell me a company that has been using mostly the very same bricks and iron at each of their new bridges (here, I refer to the fact that releases we tested had mostly the same bits of code day by day, week by week - "not much things change").

Master builders are experts recognized for having designed and / or built tens, hundreds, or thousands of things in their area.

Fine, following up your explanation of repeatability quoted above, I can say so what? Back then, our little, not very special group of testers has verified, see above ("about 500") hundreds of things in our area.

As for project developers, they have literally built ("nightly builds") - see, the word is the same, and the meaning is right in this context - hundreds things in their area.

If one wants to continue that "suspect" analogy further up to "thousands of things", these amounts are, again, nothing spectacular in software development when one looks at the right things.

As an example, yet another of my past projects (again, nothing spectacular, rather regular one), this time in dev role, has been going on for more than 5 years (8 major releases, several dozens minor ones). There were similar weekly checkpoints (5x52~=250 of them), similar nightly releases (5x365~=1800 of them) and similarly, same dev / QA teams working on these. Day by day, week by week, month by month, mostly repetitive stuff (not much change between two nightly builds) - as promised, in the range of thousands times (1800).

Longer lived projects like Windows or Java, or AutoCAD can span 10, 20, 30 years, that easily accounts for repeating as many "thousands" nightly builds and nightly tests as it gets.

Concept of repeatability shift to QA becomes even more prominent with Continuous integration...

the practice... of merging all developer working copies with a shared mainline several times a day... CI can be seen as an intensification of practices of periodic integration..

In addition to automated unit tests, organisations using CI typically use a build server to implement continuous processes of applying quality control in general — small pieces of effort, applied frequently. In addition to running the unit and integration tests, such processes run additional static and dynamic tests, measure and profile performance, extract and format documentation from the source code and facilitate manual QA processes. This continuous application of quality control aims to improve the quality of software, and to reduce the time taken to deliver it, by replacing the traditional practice of applying quality control after completing all development. This is very similar to the original idea of integrating more frequently to make integration easier, only applied to QA processes...

Repeatability? it's right there, as much of it as one can think of.

With frequent / continuous QA, things that go wrong quickly get back to developers who are forced to repeat attempts at doing it right until failing tests successfully pass. In a sense, that cycle of repeating until it passes resembles code cata,

an exercise in programming which helps a programmer hone their skills through practice and repetition...

ContentLicense: CC BY-SA 3.0

Title: Does software reuse preclude process repeatability

Body:
Code Reuse as a Problem

I was thinking about this question on software delivery, and I kept coming back to the issue of repeatability and / or reproducibility.  They matter, because if you don’t repeat a project then it becomes more difficult to improve the process you used to build the project.  Engineering involves constantly improving the processes involved with design and construction in order to produce higher quality projects.

Software can rely heavily upon reuse due to its digital form.  Instead of rewriting a module, we just call it again or copy it to the other system.  Some examples are authentication / login or perhaps a logging function.  There are many well known examples for those categories, and conventional wisdom is to reuse what exists instead of rolling your own.

Some Comparisons to Other Disciplines

Construction

In contrast, construction of physical systems (buildings, bridges) is nowhere near as reusable.  It’s true that the blueprint of a house can be reused many times to build the same copy of the house, but the construction must be performed each time.  Cut & paste doesn’t work like that in the analog world.  Bridge blueprints are less reusable that houses because site conditions will vary.

Master builders are experts recognized for having designed and / or built tens, hundreds, or thousands of things in their area.  For example, Frank Lloyd Wright, a world renowned architect and designer designed more than 1,000 structures and completed 532 works.  Contrast that with Anders Hejlsberg who has designed “just” five languages (Turbo Pascal; Delphi; J++; C#; Typescript).  In many ways, it’s an unfair comparison because the domains are different.  But at a broad level, the quantifiable production from two very intelligent people is vastly different.

Martial Arts

Martial artists will say that mastery of a move comes only from thousands of repetitions. After a good portion of those repetitions have been put in, many martial artists are surprised at how a previously perceived to be complex kata or form has become simple. Instructors of those students will also notice how the motion becomes more fluid and purposeful as well as having an economy of motion. Likewise, experienced martial artists are able to pick up more complex katas more quickly than less experienced students. Experience from repetition has given them a framework or process that allows them to learn more quickly.

Woodworking

Woodworkers experience a similar transformation. Hobbyist woodworkers always refer back to their first project that required a lot of drawers. If they complete the project, they gain a new appreciation for the efficiencies that assembly lines produce. There are other benefits such as a better understanding of how to lay out the drawers parts on the sheet stock in order to maximize use of the wood. Compared to hobbyists, professional woodworkers are able to more quickly design, start, and construct items that they have made many times before. They also gain an ability to see inherent issues within someone else's design having made that mistake in their work.

So, does software reuse prevent software developers from becoming more proficient?

In many ways, software design and construction is always new.  We don’t repeat past works, because if we can reuse a module, library, or system then we do.  We’ll preferentially extend an existing system before rewriting the entire thing from scratch.  But repetition is what allows us to find efficiency in the design and the construction. Anyone who has practiced a sport or physical activity will tell you that repetition is the key to becoming a good practitioner.

My question: Does software’s ability to be reused prevent the necessary process improvement and efficiency that comes from repeating a project?


问:
Code review if nobody in team has knowledge in some technology?
Sample situation: A team of Java developers starts an iOS project. Only one developer has Objective-C/iOS knowledge, and in the beginning he will work on this project alone.

How we can perform code reviews in this situation? What are processes, approaches, tools that this developer will use?

答:
First off, Code Review is not compilation -- it is not used to check syntax, but rather logic and design patterns/conventions.  And while there are design patterns that are somewhat platform/language specific, there are more that aren't.  Your developers should pickup enough of the syntax in order to be able to aid in spotting both logic and design issues.

Basically I think this is a non-problem -- instead, I think it's an opportunity for your Java developers to get their feet wet in the language while providing good service.


答:
Some of what you say is true: e.g. libraries solve functions not solved by high level languages which solve problems not solved by assembly which solve problems not solved by machine code.  When you call System.out.println() in java you are losing sight of how a CPU outputs to a device.

So yes, you're losing something.  What you gain is the ability to focus on unsolved problems.  Now it may be that you need to immerse yourself in some other aspects of technology ( e.g. how networks function ) to solve a problem.  But you don't need to become an expert in reading machine language when all you want to do is build a web page.

The same way, bridge builders are solving a slightly different problem every time ( its a different river ).  They don't worry about how to create steel beams of a certain tensile strength, or how to machine bolts to a certain tolerance.  They leave that to specialists who have solved that problem.

Look closely, and you'll see our entire society and infrastructure are built on 99% reuse and only 1% true progress.  Most new things are just old things with a little extra something added or removed.  It's the accumulation of human knowledge.  You can write code in a high level language with decent libraries because someone figured out all of the mind-blowingly complicated stuff required to get to this point.  It allows you to solve new and interesting problems.

To tie this all together and respond to comments:  You don't have to solve problems that have already been solved to develop proficiency.  Further, much of what you do will be reinventing the wheel.  So in short, the answer is no - you don't need to re-implement the functions of libraries to become proficient.  There is plenty of opportunity, some of it rote, some of it creative to hone your craft.


问:
Why do many PHP Devs hate using isset() and/or any of PHP's similarly defensive functions like empty()?
Over on stackoverflow, I see this issue crop up all the time:

E_NOTICE ?== E_DEBUG, avoiding isset() and @ with more sophisticated error_handler

How to set PHP not to check undefind index for $_GET when E_NOTICE is on?

How to stop PHP from logging PHP Notice errors

How do I turn off such PHP 5.3 Notices ?

Even Pekka (who offers a lot of solid PHP advice) has bumped against the dreaded E_NOTICE monster and hoped for a better solution than using isset(): isset() and empty() make code ugly

Personally, I use isset() and empty() in many places to manage the flow of my applications.  For example:

```<code>public function do_something($optional_parameter = NULL) {
    if (!empty($optional_parameter)) {
        // do optional stuff with the contents of $optional_parameter
    }
    // do mandatory stuff
}
</code>```

Even a simple snippet like this:

```<code>if (!isset($_REQUEST['form_var'])) {
    // something's missing, do something about it.
}
</code>```

seems very logical to me.  It doesn't look like bloat, it looks like stable code.  But a lot of developers fire up their applications with E_NOTICE's enabled, discover a lot of frustrating "uninitialized array index" notices, and then grimace at the prospect of checking for defined variables and "littering" their code with isset().

I assume other languages handle things differently.  Speaking from experience, JavaScript isn't as polite as PHP.  An undefined variable will typically halt the execution of the script.  Also, (speaking from inexperience) I'm sure languages like C/C++ would simply refuse to compile.

So, are PHP devs just lazy?  (not talking about you, Pekka, I know you were refactoring an old application.)  Or do other languages handle undefined variables more gracefully than requiring the programmer to first check if they are defined?

(I know there are other E_NOTICE messages besides undefined variables, but those seem to be the ones that cause the most chagrin)

Addendum

From the answers so far, I'm not the only one who thinks isset() is not code bloat.  So, I'm wondering now, are there issues with programmers in other languages that echo this one?  Or is this solely a PHP culture issue?

答: I try to avoid the use of isset() and empty() by avoiding the use of arrays as data transfer objects.  Create a class that can be configured to accept a limited set of properties with sane defaults and validate input to those properties.  It can even implement the ArrayAccess interface so you can use it like an array.  This also allows you to use type hinting in your method signatures to catch errors when someone attempts to pass the wrong type of entity to your method.</p>

ContentLicense: CC BY-SA 2.5


问:
Web Application Development Question
I checked all the relevant question's of my query and their answer's but my questions aren't exactly listed anywhere.

Basically i have just one year of web development experience using joomla , HTML , PHP etc.I have had .NET Training during my academics and now i have a requirement for a professional type .NET web application for a client.Since i don't have .NET production experience i want to ask and discuss few question's and have an advice from the expert's.

Scenario and Scope of the Project : I am required to develop a web application for hotel management in .NET with modules like

User management ( actually roles like , administrator , reservation counter user ,     restaurant user etc ) with limited functionalities for each user except for the admin.

Reservation Module ( includes reservation stuff , alloting room's etc )

Billing Module (Includes pending bills from all department's at the time fo guest check out )

Reporting Module ( I am confused with this module.i actually want to incorporate a graphical type of a view to show to the end user but i dont think i can get that done using crystal report's.Your Suggestion for this module would definitely help )

Rates Setup.

So , now i want your suggestion as to what should i start first and their best practises ?

Database Designing.

GUI Designing.

Coding.

In my opinion , coding should be the last.isn't it ?

Also , please advise on security issues too as this is a web application so this must be safe and secure.I wont be using a SSL Certificate so the application would have to run on http only.

P.S we are two developer's both have same experience if you could also share about how we can distribute modules among each other and how we can work on the same application accessing it through two laptop's locally only ?

Thanks a lot and please dont get my question locked , removed as i couldn't find a relevant answer so this cant be a duplicate one or its context it too large.The question's have been clearly mentioned.Thanks again.

答:
If you ask me (and you did) i wouldn't try to focus on the order of the steps (Database, GUI, Coding, DOCUMENTATION), because i'm a TDD/Agile advocate. Focus on writing one micro FEATURE at a time, and refactor/expand on a working mini system.

For example, start with an authentication portal where you only can login with a fixed username/password; next step is to add a database of users & roles, then add a feature to manage those users, etc.  Another start would be to show a static map of room availability.

By doing it Agile, will stop you from over-designing a feature. It also helps to design your solution gradually. With most products, you only know what you really wanted to build at the end. With Agile, that effect is much less because after iteration 1 you have a working system.

EDIT: To answer your question on working as a team, I advise you to use a revision control system. Anything is better than none here. There's Subversion, SVN, Git, Mercury, and many more. For a closed-source project, i have very good experiences with the free BitBucket. It also comes with a free issue management tool.

Title: Web Application Development Question


问:
Mocking complex data operations in integration tests
We have some problems figuring out how to mock complex data and operations on it.

First the problems with generating complex data:

In one of our components we have really complex data structures where the logic of our classes is executed. Unfortunate there are some bugs, where it is necessary to use a big data model to reproduce the case in a unit or integration test. The first idea was to write a script which converts the model to executable code, with which the data can be generated. To show the complexity of the models, these converted models had 20000++ line of code per model.

The problem with the first approach was, that we had some little mistakes in our script and every time we identified one we had to rewrite all models. That was no good idea. The second idea is to use the xml files in which they are saved. Before the test starts we use a class to convert the xml file to the model. The result is better than the first idea, but with this we will never have plain unit tests, because we always rely on the class used for the conversion.

Has someone a better idea how to deal with this issue?

The second problem is even harder to solve: manipulation of this complex data.

We have a integration test of another component and want to mock all its dependencies. Somehow we create the initial data used by the component (some kind of AST). Now we a syntax check component as a dependency. This component takes in the data and decorates the data. So in the end we have another manipulated AST in the test.

Here we have no idea, how to mock this behavior of the syntax check.

答:
```<code>   > We use a class to convert the xml file to the model. ...
   > But with this we will never have plain unit tests.
</code>```

We use a similar approach. Since we already have json (de-)serialization we use this instead of xml. The sample data is included as a test-resource so we do not rely on filesystem-stream to use the data.

To further reduce the test-dependency on huge data modells in the modell we seperate model-navigation from modell-businesslogic-calculation. Example:

There is a static modell-businesslogic-calculation-method without navigation

```<code>Order.calculateTotal(IOrderItem[] items, ICustomer customer)
</code>```

and a method that uses navigation-methods

```<code>Order.calculateTotal() {Order.calculateTotal(this.getItems(), this.getCustomer())}
</code>```

To test order-businesslogic-calculation we do not need to mock an Order. We use the internal static order-businesslogic-calculation-method that has no dependencies to the Order-OrderItems and Order-Customer.

To test Manipulation of this complex data have a look at approvaltests. approvaltests actually record test-output and fail if the test-output has changed. Then a human has to approve that the calculation was ok. The next time the approved test is rexecuted the test will not fail any more (until output changes again)

Body:
   > We use a class to convert the xml file to the model. ...
   > But with this we will never have plain unit tests.

We use a similar approach. Since we already have json (de-)serialization we use this instead of xml. The sample data is included as a test-resource so we do not rely on filesystem-stream to use the data.

To further reduce the test-dependency on huge data modells in the modell we seperate model-navigation from modell-businesslogic-calculation. Example:

There is a static modell-businesslogic-calculation-method without navigation

Order.calculateTotal(IOrderItem[] items, ICustomer customer)

and a method that uses navigation-methods

Order.calculateTotal() {Order.calculateTotal(this.getItems(), this.getCustomer())}

To test order-businesslogic-calculation we do not need to mock an Order. We use the internal static order-businesslogic-calculation-method that has no dependencies to the Order-OrderItems and Order-Customer.

To test Manipulation of this complex data have a look at approvaltests. approvaltests actually record test-output and fail if the test-output has changed. Then a human has to approve that the calculation was ok. The next time the approved test is rexecuted the test will not fail any more (until output changes again)


问:
Will high reputation in Stack Overflow help to get a good job?
In a post, Joel Spolsky mentioned that 5 digit Stack Overflow reputation can help you to earn a job paying $100k+. How much of that is real?

Would anyone like to share their success in getting a high paid job by virtue of their reputations on Stack Exchange sites?

I read somewhere that, a person got an interview offer from Google because a recruiter found his Stack Overflow reputation to be impressive. Anyone else with similar stories?

答: A nice opportunity, your skills and (hopefully) a good recruiter will get you the job. Reputation in SO (or others) is as likely to help you as to fire back at you. There's many ego wars going on in here...</p>


问:
When does SOAP make more sense than REST?
From my understanding of REST, the implicit assumption is that all operations are CRUD operations. Sometimes, you are not doing CRUD operations and are doing some more complex logic. In this case, is not SOAP more suitable? Or is it the case that all operations no matter how complex are a series of CRUD operations so they should be split up into a set of smaller CRUD operations to be called one after the other? But, does this not make the operation you are attempting more cumbersome to write? I am trying to understand when it might make more sense to use SOAP instead of REST.</p>

答:
SOAP gives you a well defined contract (WSDL) that is easily accessible to your clients. With the right technology, it makes it very easy to generate native APIs for your service.

This contract is also useful for clients to create fake implementations of the service for testing purposes.


问:
User Authentication & Session Management
One of the fundamental ways of handling user login authentication & session management is by storing variables in Session space plus setting some data in cookies on client computer while sometimes in database as well.

I have been using this simpler technique in many of my academic as well as a few online projects. But I am a little unsure about it.

Do security critical websites like Amazon, Gmail or Facebook use the very same technique for user login & session management or is there more to it than I have known?

This could turn out to be a very general question but I'd really like to know if there are other or mix of multiple ways used (like at gmail, stackexchange or myspace) for handling user login authentication & session management in particular.

答:
If you use any of those sites, look at your browser's cookie store - you'll see that they're doing exactly what you ask.

The main issues with cookies and security are that they're stored on the client machine and transmitted back and forth to the server - so you don't want to be storing important information (such as user passwords)!

Consider using HTTPS to make session fixation attacks (where an attacker sniffs the session ID as the client transmits it to the server and uses that to masquerade as the client) a bit more difficult; in a number of cases (Facebook uses extra steps to confirm your identity if you use a new IP address, the Bugzilla/Mantis bug trackers both ask you to login again), sessions are invalidated if some other identifying feature such as IP address changes and sessions can have a timeout which can also reduce the value of stealing the session ID.

Lastly, since they're (sort of) user input, you shouldn't trust them! Take the usual precautions to avoid things like SQL injection etc.


问:
XML/HTML: Do we need the element name in closing tags?
Compared to other serialization languages, one of the main criticisms directed at XML is its verbosity; JSON's more terse and readable for most cases, but not all.

But it seems to me that we could cut a lot of the excess from XML simply by stripping away the names from the closing tags. With proper indentation readability shouldn't be an issue (it should be an improvement, if you ask me), and since they're not structurally required any decent XML editor/viewer could easily be made to strip/hide or add them. As such, the two formats should be completely equivalent and interchangeable.

Compare the following (source taken from http://www.w3schools.com/xml/simple.xml):

```<code><breakfast_menu>
    <food>
        <name>Belgian Waffles</name>
        <price>$5.95</price>
        <description>
                    Two of our famous Belgian Waffles with plenty of real maple syrup
        </description>
        <calories>650</calories>
    </food>
    <food>
        <name>Strawberry Belgian Waffles</name>
        <price>$7.95</price>
        <description>
                    Light Belgian waffles covered with strawberries and whipped cream
        </description>
        <calories>900</calories>
    </food>
    <food>
        <name>Berry-Berry Belgian Waffles</name>
        <price>$8.95</price>
        <description>
                    Light Belgian waffles covered with an assortment of fresh berries and whipped cream
        </description>
        <calories>900</calories>
    </food>
    <food>
        <name>French Toast</name>
        <price>$4.50</price>
        <description>
                    Thick slices made from our homemade sourdough bread
        </description>
        <calories>600</calories>
    </food>
    <food>
        <name>Homestyle Breakfast</name>
        <price>$6.95</price>
        <description>
                    Two eggs, bacon or sausage, toast, and our ever-popular hash browns
        </description>
        <calories>950</calories>
    </food>
</breakfast_menu>
</code>```

and

```<code><breakfast_menu>
    <food>
        <name>Belgian Waffles</>
        <price>$5.95</>
        <description>
                        Two of our famous Belgian Waffles with plenty of real maple syrup
        </>
        <calories>650</>
    </>
    <food>
        <name>Strawberry Belgian Waffles</>
        <price>$7.95</>
        <description>
                        Light Belgian waffles covered with strawberries and whipped cream
        </>
        <calories>900</>
    </>
    <food>
        <name>Berry-Berry Belgian Waffles</>
        <price>$8.95</>
        <description>
                        Light Belgian waffles covered with an assortment of fresh berries and whipped cream
        </>
        <calories>900</>
    </>
    <food>
        <name>French Toast</>
        <price>$4.50</>
        <description>
                        Thick slices made from our homemade sourdough bread
        </>
        <calories>600</>
    </>
    <food>
        <name>Homestyle Breakfast</>
        <price>$6.95</>
        <description>
                        Two eggs, bacon or sausage, toast, and our ever-popular hash browns
        </>
        <calories>950</>
    </>
</>
</code>```

答:
Can we change XML format (i.e. create a new language which doesn't have the verbosity issue)? Yes, we can.

In order to completely migrate to the "better XML" (let's call it BETXML), it would require to:

Reimplement all the parsers,

Rewrite all applications which currently use XML,

Rewrite all protocols based on XML.

Or we can keep everything in place, and just invent a new language and wait until it starts to be adapted everywhere. The only issue is that benefits of a new language are very limited. Applications which require less verbose language already use JSON. How would you convince people that BETXML is superior to XML and JSON?


问:
Career advice: stay with PHP or start a new career in something else ( .Net?)
I'm planning on moving to NY in 6-12 months tops, so I'm forced to find a new job. When I'm planing to start my life in another city it's also probably a good time to think about career changes.

I've found a lot of different opinions about PHP vs .Net vs Java and this is not the topic here. I don't want to start a new fight about which language is better. Knowing a programming language is not the most important thing for being a software developer. To be a really good developer you need to know OOP, design patterns, testing... and a language is just a tool to make things happen.

So back to my question. I have mixed experience in IT - 1 year as an IT support guy (Windows administration and support), around 2 years of experience in embedded programming (VB.Net 2005) and for the last 2 years I'm working with PHP/MySQL. I have worked with Magento web shop, assisted in some projects in Symfony, modified few Drupal sites.

My main concerns are the following:

Do I continue to improve my skills in PHP e.g. to start learning some major PHP framework like Zend, Symfony maybe get some PHP certification.

Or do I start learning .NET or Java. I'm more familiar to .NET so I'll probably choose it if choice falls between .NET and Java ( or you could convince me to choose Java :).

Career-wise, I don't know what is the best choice. Learning a new framework and language is more time consuming then improving my existing skills in PHP. But with .NET you have a lot of possibilities (Windows 7 Phone development, Silverlight, WPF) and possibly bigger chances to find better jobs.

PHP jobs are less well payed then .NET, at least, according to my research (correct me if I'm wrong). But if I start now with .NET I'm just a beginner and my salary will be low. I need at least 2+ years of experience in some language to even try to find some job that is paying higher than $50-60k in NY. My main goal in the next 2-3 years is to try to find a job in the $60-80k category. Don't get me wrong, I'm not just chasing money, but money is an important factor when you're trying to start a family.

I'm 27 years old and I feel that there isn't a lot of room for wrong decisions regarding my career, so any advice will be very welcome.

Update

Thank you all for spending time to help me with my problem. All of the answers and comments have been very helpful. I have decided to stick with PHP but also to learn C# and Silverlight 4. We'll see where the life will take me.

答:
Short term; I don't know what the hiring practices are in the US, but considering you are moving in 6~12 months I would, for the time being, consider sticking with PHP since you have two years of experience with it.

My experience here (in the Netherlands) is that companies tend to have a very short term focus on technologies and framework experience.
The language is really not -it-, even if they are asking "3 years of C# experience" they mean to say "3 years experience with the framework/class libraries and tools you'd be using with C#".

(Otherwise, why they want to hire anyone needing 3 years to learn C# syntax and language features is beyond me. It sounds like someone I wouldn't want to hire.)

Learning new languages; static, dynamic, functional, is of great value when it comes to broadening your perspectives. However learning the relevant class libraries and way of doing things in that language will require experience.

I'd recommend coming to a decision picking one technology stack and learning it deeply. Use the other environments for inspiration.

Of course personal preference comes into play also. For instance, while there is plenty of market for it, I would never ever accept a PHP job :-P I choose a stack and I job hunt based on that.

As for making a career, long term, I think you should look beyond coding (in the end it's all about learning and being able to read and/or skim documentation) and the technology of the day and look more into soft skills and such. Technologies come and go rather quickly.
Of course there is a lot to learn when it comes to good practices and more general know-how, unfortunately they are rarely looked for on the job market in my experience.


问:
Rest API Architecture from Rest in Practice book
We maintain an API that as part of its purpose makes a call to an external API. This external API takes a few seconds to fulfil the request we make to it. With our current architecture the request is made synchronously, meaning that the http response we return to the user request is blocked until our service get the response from the external API.

I am considering changing our architecture to be able to deal with the request asynchronously... By this I mean accept the user request into our API and put a message on a queue so that we return an http response a lot quicker. The response would contain the address of where the full/complete result can be found. A background task would then pick messages up from the queue and make the call to the external API, then store the result at the address provided in our response. The address could then be polled by the user/client until the desired state of the respource is reached (i.e. when the background task has finished calling the external api and has stored the result).

This architecture I have mainly lifted from the REST in Practice book. The crux however is that our external API only takes 2-3 seconds to return the response. The example in the book describes an ordering process that might take minutes or hours. Is this suggested solution worth the increase in complexity for such a short response time from our external dependency? i.e. will the application still scale with the existing synchronous architecture?

答:
There is nothing in REST that stops you from mixing synchronous and asynchronous solutions per resource and method combination.

For example in our query server we return almost everything synchronously as the resources/information are readily available. Only when a new query is posted, do we go the route of generating an identifier and returning an "Accepted" or "See other" (303) response with the URI of the query results resource in the body as well as the location header. Returning information about the query and the query results themselves is done synchronously again.

update

Don't have any numbers on the average delay before result data is available for a posted query. We are still working on the REST implementation. However, queries in our current architecture usually take milliseconds to complete (we are sort of an in-memory database), though we have customers where some queries are known to take 20 minutes to return a result. So in a sense the need for asynchronicity isn't so much the average delay, but the fact that we do not want to have any requests that could block a connection for any serious period of time (> 1 second or so) and customers can post queries that run for more than that.

To give a few more details on the asynchronous execution of queries:

The "query result" is a resource that holds the basics about the results of a posted query: identifier, status (progress), uri for the result data (empty / absent until that is available), those kinds of things.

The new "query result" resource is stored immediately and before the response to the POST is returned.

The query process updates the "query result" with its progress and ultimately with the total number of rows in the result data.

In other words: the new "query result" resource is queryable as soon as the POST returns. It just isn't complete yet. Polling the query result will show status and progress and once the query process finishes, status will be finished and the uri for the result data will have a value.


问:
Differences between different creative coding libraries
I've worked with Cinder previously under Windows, but have recently switched to Ubuntu. Since Cinder doesn't work on Linux (::sadface::) I've began looking for alternatives. With that in mind, could you please tell me what the differences between Processing, openFrameworks and Polycode are, and compare them to Cinder?

Specifically, I would like to know

If there are differences in the functionality of the packages compared to Cinder (ie. one does something that Cinder doesn't and vice versa).

I would also like to know how different the syntax of the package is from Cinder's.

I have already seen the following articles: here and here and have also visited the corresponding website for each of the libraries but could not find a clear and concise answer to my question.

答:
The things that come to mind are that

Processing is the only one which is not C++ (but Java) in that bunch

I think openFrameworks is the one with the broadest platform support right now (Win, Mac, Linux, iOS, Android, with raspberryPi incoming currently)

Polycode is the youngest (with no judgement if that's good or bad)

OwnerDisplayName: lazyCrab

OwnerDisplayName: Christoph


答: It’s good to stick with the platforms with a big community and active development. For me, this currently is Processing and openFrameworks. I use Processing because of it’s simplicity and openFrameworks for applications with high demands on performance.

Title: Differences between different creative coding libraries

Body:
I've worked with Cinder previously under Windows, but have recently switched to Ubuntu. Since Cinder doesn't work on Linux (::sadface::) I've began looking for alternatives. With that in mind, could you please tell me what the differences between Processing, openFrameworks and Polycode are, and compare them to Cinder?

Specifically, I would like to know

If there are differences in the functionality of the packages compared to Cinder (ie. one does something that Cinder doesn't and vice versa).

I would also like to know how different the syntax of the package is from Cinder's.

I have already seen the following articles: here and here and have also visited the corresponding website for each of the libraries but could not find a clear and concise answer to my question.

OwnerDisplayName: Pwdr


问:
Operator distributivity in expressions - syntactic sugar
When writing boolean expressions out, you often have to use something of the type:

```<code>A == any of B1, ..., Bn
C < all of D1, ..., Dm
</code>```

But in code you have to use expanded forms:

```<code>A == B1 or ... or A == Bn
C < D1 and ... and C < Dm
</code>```

That looks, to me, like any of and all of are simply the distributed form of or and and. That made me wonder if you can apply distributivity to operators in some way that compilers/interpretors can understand. For the above example, say, something like this:

```<code>A == B1 +_or ... +_or Bn
C < D1 +_and ... +_and Dm
</code>```

Essentially, taking operators as relations, it should work something like this:

```<code>R1(A, distributive_R2(B1, ... , Bn)) becomes
R2(R1(A, B1), ... , R1(A, Bn))
</code>```

This could apply to more than just booleans:

```<code>X / Y1 +_+ ... +_+ Yn becomes
X/Y1 + ... + X/Yn
</code>```

Of course, my +_ prefix may not be the ideal syntax; I'm sure there's better ones out there. Nevertheless, this strikes me as being possibly quite useful and understandable. Any thoughts?

答:
1. I don't like the syntax

A == B1 or ... or A == Bn is not obvious. It is for simple forms, but those simple forms are rare. For example, there is no need to write:

```<code>A == 1 or ... or A == 10
</code>```

when you can simply write:

```<code>A >= 1 and A <= 10
</code>```

If you enumerate through the sequence, the syntax won't help neither:

```<code>Set = [ 4, 7, 2, 3, 0, 1, 1 ]
A == Set[0] or ... or A == Set[Set.Length]
</code>```

is too verbose.

Also, what would:

```<code>A == 1 or ... and A == 10
</code>```

mean? If this is illegal, how an IDE would prevent it? Why forcing the developer to type the same word twice?

Readability should be your concern too. C < D1 +_and ... +_and Dm in your question is already difficult to understand. I can't imagine a piece of code which combines several ranges.

2. in and ranges in SQL and Ada

The easier syntax would be the one which is already used in SQL for keywords and in Ada and Matlab for ranges:

```<code>A in 1..10
</code>```

or:

```<code>A in Set
</code>```

Some SQL variants also use between:

```<code>A between 1 and 10
</code>```

I largely prefer Ada syntax 1..10, which is extremely explicit and shorter to write. The and keyword makes the reader think about a boolean operation, not a range. Without knowing the syntax, some developers will also be tempted to write either:

```<code>A between 1, 10
</code>```

or:

```<code>A between(1, 10)
</code>```

The SQL/Ada syntax is nice when it comes to searching a value in a set or a range, but not when it comes to verifying that an expression is true for any value of a sequence. I don't know if those languages have constructs allowing that.

3. C# world, as a side note

Note that in C#, which uses some paradigms from functional programming and has lambda expressions, your suggested syntax would be written this way:

Searching for a value in a sequence:

```<code>var isInList = sequence.Contains(value);
</code>```

or:

```<code>var isInList = sequence.Any(a => a == value);
</code>```

Verifying that en expression is valid for any element of a sequence:

```<code>var trueForAll = sequence.All(a => a > 0);
</code>```

Filtering:

```<code>var positiveOnly = sequence.Where(a => a > 0);
</code>```

This is not the best syntax ever, and I largely prefer the one which is inspired by SQL/Ada, but it gives you some ideas about how your problem is solved in different languages.

You can use this syntax to create your own, with specific language keywords. Something like:

```<code>A in Set              # Verifies that Set contains A.
B in 1..10            # Verifies that 1 ≤ B ≤ 10.
C > 0 for any Set     # Verifies that all elements of Set are positive.
D <> 0 for any 1..10  # Verifies that none of the values between 1 and 10 are equal to zero.
</code>```

Body:
1. I don't like the syntax

A == B1 or ... or A == Bn is not obvious. It is for simple forms, but those simple forms are rare. For example, there is no need to write:

A == 1 or ... or A == 10

when you can simply write:

A >= 1 and A <= 10

If you enumerate through the sequence, the syntax won't help neither:

Set = [ 4, 7, 2, 3, 0, 1, 1 ]
A == Set[0] or ... or A == Set[Set.Length]

is too verbose.

Also, what would:

A == 1 or ... and A == 10

mean? If this is illegal, how an IDE would prevent it? Why forcing the developer to type the same word twice?

Readability should be your concern too. C < D1 +_and ... +_and Dm in your question is already difficult to understand. I can't imagine a piece of code which combines several ranges.

2. in and ranges in SQL and Ada

The easier syntax would be the one which is already used in SQL for keywords and in Ada and Matlab for ranges:

A in 1..10

or:

A in Set

Some SQL variants also use between:

A between 1 and 10

I largely prefer Ada syntax 1..10, which is extremely explicit and shorter to write. The and keyword makes the reader think about a boolean operation, not a range. Without knowing the syntax, some developers will also be tempted to write either:

A between 1, 10

or:

A between(1, 10)

The SQL/Ada syntax is nice when it comes to searching a value in a set or a range, but not when it comes to verifying that an expression is true for any value of a sequence. I don't know if those languages have constructs allowing that.

3. C# world, as a side note

Note that in C#, which uses some paradigms from functional programming and has lambda expressions, your suggested syntax would be written this way:

Searching for a value in a sequence:

var isInList = sequence.Contains(value);

or:

var isInList = sequence.Any(a => a == value);

Verifying that en expression is valid for any element of a sequence:

var trueForAll = sequence.All(a => a > 0);

Filtering:

var positiveOnly = sequence.Where(a => a > 0);

This is not the best syntax ever, and I largely prefer the one which is inspired by SQL/Ada, but it gives you some ideas about how your problem is solved in different languages.

You can use this syntax to create your own, with specific language keywords. Something like:

A in Set              # Verifies that Set contains A.
B in 1..10            # Verifies that 1 ≤ B ≤ 10.
C > 0 for any Set     # Verifies that all elements of Set are positive.
D <> 0 for any 1..10  # Verifies that none of the values between 1 and 10 are equal to zero.


问:
How to Protect Intellectual property violations from one's own team
I have an android app idea, I want to make the app along with a few batch-mates in my collage.

(1)  How do I make sure that these guys will not compromise the intellectual properties involved? In the sense that they will not leak out confidential information, new theories, new ideas, new features descriptions either freely on any medium or to some other company developing similar software. Also, these people will most likely have access to the entire source code (with comments) of the project, how do I make sure that in the future they will co-operate with me,

(2) will not release any part of the code,

(3) Will not freely release alpha versions containing features meant only for premium users. Also,

(4) is there way to effectively work without granting them access to the entire source code?

I am open to all kinds of answers: trust, technical, managerial - leadership, good friendship - relationship with collegues.

UPDATE: We all live in India.

答:
I know little about India's legal system but consider intellectual property laws. For example, if your idea is patentable, consider patenting it. Yes, this is expensive (and not popular with some people) but this is what patents are for. Make sure each source code file includes a copyright notice. IP law will not stop people stealing your code and ideas but you may be able to prevent them from using them.

If your idea builds upon or integrates with another product or organization. Consider talking to that organization and see if you can work out a preferred or sole licensing arrangement. Hypothetically, if your app is going to market soft drinks, approach soft drink companies and pitch your idea. If they like it, they might fund it, give you technical help and deny that assistance to others.

For technical controls, consider componentizing the system and using segregation of duties. Specifically:

Split the development team into separate teams. Physically separate them so the developers in one team cannot talk to others.

Split the product into components with well defined interfaces and assign each team a different component.

Place the source code of each component in a separate source control system and deny other teams access to that component.

When componentizing, consider vertical slices of the system (e.g. UI, business logic and storage) rather than horizontal layers (e.g. 1 UI team, 1 business logic team, etc). Otherwise, each team may see too much of the system.

This way, each team will know their component but, if someone talks or takes code elsewhere, the worst they can do is talk about their component. You often see this approach in very security-sensitive systems.

For network accessible components, use authentication, auditing and using different development and production credentials. Specifically:

Have each interface require authentication, e.g. a user name and password.

Supply development testing credentials but use different credentials in production

Keep an audit log of accesses and regularly review it.

This ensures any these components are used only for their intended purposes. This may be a reason to move some functionality off the app and onto cloud services, for example.

That said, anything that impairs information sharing within the team is likely to impact team morale and performance. Effectively, you are saying you do not trust your development team. In that case, how can you expect them to trust you? If you trust your developers and share your success with them, they will work harder because it is their product, too.

Also, be aware that the key to most new projects is its execution, not the initial idea. Your idea might be great but, chances are, it is going to change a lot as you develop your product and expose it to customers.


问:
What is good practice when inheriting static classes isn't possible/allowed
I am developing a project in C# and due to a design decision it is not possible to have a static class inherit another static class. But I have, in my opinion, a case where this would make sense.

I have a music player which is able to play music from many different music sources: local files, YouTube, SoundCloud, Jamendo, etc. I have currently one static class for each of these sources with static methods such as retrieving the top tracks, searching for tracks, etc.

Naturally, a lot of code is shared among all these classes so I wanted to refactor and put all common code into a more generic MusicSource class. But C# doesn't allow me to do that.

What would be the best practice here? I want to get rid of all my redundant code and make it easier to create new music sources.

答:
Using static in this case is completely wrong. People tend to use static's way to often! Basicly you have 1 "MusicPlayer" with X-amount of implementation (youtube, ...) So the first thing that should pop up in your head is inheritance.

They will all do the same, but abit different => Inheritance.
You want your application to work with several kinds of sources, without any need to adapt the application itself => Inheritance/Interface segregation.

Static classes can be useful, but in this case I have a feeling that the Music classes are the core of your application... Don't build your core functionality in static classes, since you remove: testability, maintainability, reusability, extensibility, ...

You say:

I want to get rid of all my redundant code and make it easier to
  create new music sources.

Here again, inheritance is central...

In C#, whenever u use static classes forget about inheritance. The other way around, whenever u need inheritance, forget about static classes.

Why did you initially make them static anyway?

If you want to have only one instance available, make it a singleton. If not, just make it non-static!


问:
Code formatting SQL queries
Should I break SQL queries in different lines? For example in the project I am working on, we have a query that is taking 1600 columns! 1600 + tab chars. I wrote queries like this:

```<code>   "SELECT bla , bla2 , bla FROM bla " .
     "WHERE bla=333 AND bla=2" .
      "ORDER BY nfdfsd ...";
</code>```

But they demanded me to put them in one line and said that my style is bad formatting. Why it is bad practice?

答:
Multiline comments are good, almost vital when dealing with large volumes of SQL. And if your programming language has heredoc quotes, it's even better (as many editors can highlight SQL syntax in them).

Example:

```<code>$a = SQL<<<
    SELECT a, b, c, d
    FROM Foo f
    WHERE f.a = ?
SQL;
</code>```

When working with queries of dozens of lines (or hundreds) both the indentation and whitespace make the text workable.

Title: Code formatting SQL queries

Body:
Multiline comments are good, almost vital when dealing with large volumes of SQL. And if your programming language has heredoc quotes, it's even better (as many editors can highlight SQL syntax in them).

Example:

$a = SQL<<<
    SELECT a, b, c, d
    FROM Foo f
    WHERE f.a = ?
SQL;

When working with queries of dozens of lines (or hundreds) both the indentation and whitespace make the text workable.


问:
How do I license my software under a free license?
I wrote a number of NodeJS modules (some of which are actually good, in my modest opinion). I basically forgot to set a license for them.

I would like to pick the AGPL (Affero GPL).

How do I do that? Can I just get away with a LICENSE file in the project? Or do I need a license disclaimer in every single file in the project? What about CSS?

答:
NOTE: I am not a lawyer. If you are making business decisions, I recommend getting professional legal advise first.

In most cases, merely adding a LICENSE file to your project should be sufficient and is common convention in open source projects. If you are concerned, reference your LICENSE file from any documentation you have. You should not need to reference it from every file unless your license is restrictive or unusual and most open source licenses are neither.

That said, take a step back and ask why do you want to add a license? For example:

Protect yourself by disclaiming any warranties.

Control how others modify your software and distribute those modifications.

Control whether others can resell or distribute your software.

Appear more professional by specifying a license (don't laugh, it happens).

If you are concerned about warranties, the worst case scenario is something taking you to court. You could consider professional indemnity and personal liability insurance but this is expensive but, without knowing your project, you would be extremely unlucky to need it.

If you are concerned about people copying or taking credit for your work, specifying a license may be insufficient. You could close source your software but this hard for JavaScript. You could also make the code publicly available so any blatant copying is easily found by a Google search but that defeats the purpose of using an open source licence.

In short, the big thing you want to do is control how others use and modify your code and the LICENSE file does not, by itself, prevent anyone from doing anything. What it does do is give you some legal and moral recourse if someone abuses it and making a reasonable effort to define that, such as adding a LICENSE file and referencing it from other documentation, is usually sufficient.

OwnerDisplayName: Merc


问:
Licensing open source controls iOS
I am confused about using licensed open source control in my comercial iOS application. Do I have to include any license in my code or i can just add open source control and push app to app store?

For example have look on following

https://www.cocoacontrols.com/controls/klnoteviewcontroller

It has two lincenses. I can download it for free using Apache 2.0 License but I am not sure if   I can use it my paid iOS application.

Please advice

答: The license is written in the code itself so you do not have to include anything extra .... The control is for you to use at your disposal.... And since you used the free one there is no need to do anything extra . I have used loads of controls and have apps live on the App Store and I havent faced any such issue and there is no commercial license problem...  Hope this helped.</p>

Title: Licensing open source controls iOS

OwnerDisplayName: IronManGill


答:
The Apache 2 license is considered as permissive. You can include Apache 2 license code in your commercial application and you can distribute/sell your software under an other license (commercial) without the need to redistribute the source code.

Your only requirement is to add a notice text for informational purpose only. For example, include somewhere (for example in the About menu): This software includes parts of "KLNoteViewController" under Apache 2 license.

Keep also the Copyright notice in the source code.

The "Redistribution" paragraph is the most interesting for you.

To sum up this paragraph in easier terms:

1. Add the Apache 2 license in the source code & somewhere viewable by your end users

2. If you modify a source code which was under the Apache 2 license, you still need to include the Apache 2 license at the top of this source code add write that this file has been modified

3. Do not delete the original copyright notices

4. If a NOTICE file was included in the original code, redistribute it in the way you prefer (for example a popup in the third parties notice menu)

https://en.wikipedia.org/wiki/Apache_License

PS: Adding the Apache 2 license text seems stupid for an app that you will never open source. However, it is still useful if you sell your source code to another company. They will be able to check where some original open source software comes from.

Title: Licensing open source controls iOS

Body:
I am confused about using licensed open source control in my comercial iOS application. Do I have to include any license in my code or i can just add open source control and push app to app store?

For example have look on following

https://www.cocoacontrols.com/controls/klnoteviewcontroller

It has two lincenses. I can download it for free using Apache 2.0 License but I am not sure if   I can use it my paid iOS application.

Please advice

OwnerDisplayName: poiuytrez


问:
Does using Creative Commons No-Derivatives license conflict with GitHub terms?
When a software project wants to use Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License that denies making derivatives, does it conflict GitHub terms of service clause F.1 that says:

By setting your repositories to be viewed publicly, you agree to allow others to view and fork your repositories.

Eg. is forking (allowed by GitHub) the same as making derivatives (denied by CC). A fork has an owner, has its own download links, has separate history from the original repo etc. and any other feature you might expect from a "derivative".

I know that using CC for a software project is not the brightest idea but some are still doing this and I wonder if it is even allowed by the GitHub terms.

IANAL is OK, I just want to see some opinions about it

答:
Github doesn't force any licensing by default, and most of the code hosted on Github is not licensed.

You're basically free to use the license you want, but please consider this article before.

I am not a lawyer so I don't know the exact terms of service of Github, but, as apsillers was commenting, doing a git clone is not prohibited as long as no modifications are made to the code. (you will need a license that at least authorize to see and download the code, but you shouldn't be using github if you're not ready to do that anyways...)

OwnerDisplayName: Andris


问:
I have only two languages on my resume - how bad is this?
I have a question that can be best answered here, given the vast experience some of you guys have!

I am going to finish my bachelor's degree in CS and let's face it, I am just comfortable with C++ and Python. C++ - I have no experience to show for and I can't quote the C++ standard like some of the guys on SO do but yet I am comfortable with the language basics and the stuff that mostly matters. With Python, I have demonstrated work experience with a good company, so I can safely put that.

I have never touched C, though I have been meaning to do it now. So I cannot write C on my resume because I have not done it ever. Sure I can finish K & R and get a sense of the language in a month, but I don't feel like writing it cause that would be being unfaithful to myself.

So the big question is, are two languages on a a resume considered OK or that is usually a bad sign? Most resumes I have seen mention lots of languages and hence my question. Under the language section of my resume, I just mention: C++ and Python and that kinda looks empty!

What are your views on this and what do you feel about such a situation?

PS: I really don't want to write every single library or API I am familiar with. Or should I?

答:
The number of languages on your resume is irrelevant.  Having the languages on your resume that your employer uses is what's important, and even that is negotiable.

I've passed on people who "knew the language" in favor of someone with a good foundation in Computer Science and knowledge of a programming language "close" to the one we use.  Learning a language's syntax is often trivial.  Learning the language idioms, and standard approaches usually take more time.

BTW I only put languages I'm current with in my resume.  You won't see eiffel, scheme, C, etc.  I don't put Java on there either, but that's because I dislike using the language.


答:
Generally, the term "forking" means taking some codebase and making a modified version of it. However, Github uses the term "forking" to mean "use of Github's fork feature", which simply creates an unaltered clone of a repository by use of git clone.

A fork has an owner, has its own download links

If you consider trivial alteration of related metadata to constitute the creation of a derivative work, I don't see how anyone could ever legally share a copy of a CC-ND work. If I put up someone else's CC-ND video on YouTube, have I created a derivative work because my username is different from the author's, or the URL where the video is available is different? If you think the answer is "yes, that's a derivative work", then it seems impossible to share a CC-ND work at all, which is contrary to the entire point of the license.

A fork has... separate history from the original repo

It does not -- the fork actually has a history identical to the original repo. That's the entire point of git clone. If you're worried that your repo may differ at some future time because the original author created a modified version, that's not a valid concern, either. Imagine if I shared someone else's CC-ND music on my website: if the original artist modified some of his tracks, I have no responsibility to update the old versions of the tracks I'm currently sharing.

From the information you've presented here, it looks like Github has nothing to say about you restricting modifications on your repo content.

Title: Does using Creative Commons No-Derivatives license conflict with GitHub terms?

Body:
When a software project wants to use Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License that denies making derivatives, does it conflict GitHub terms of service clause F.1 that says:

By setting your repositories to be viewed publicly, you agree to allow others to view and fork your repositories.

Eg. is forking (allowed by GitHub) the same as making derivatives (denied by CC). A fork has an owner, has its own download links, has separate history from the original repo etc. and any other feature you might expect from a "derivative".

I know that using CC for a software project is not the brightest idea but some are still doing this and I wonder if it is even allowed by the GitHub terms.

IANAL is OK, I just want to see some opinions about it


答:
Ok, you have an idea, good.  I'm sure your friends have their own too.  If you want them to work on yours, I see few options:

pay them for their work.

talk with them, pool the best ideas, come up with a new one that belongs to everybody.

start it yourself, when it's already rolling, call them.

In the first case, you can be sure to make it clear who owns what, and talk very specifically about what you expect they won't do.

In the second case, you share the interest and the risks. drafting a compromise not to stab each other in the back is still a good idea.

In the third case, it might be easier to convince them to work in your idea, and it's a little obvious that you started it all; but still have to write somewhere what belongs to whom, from the start.  That also implies recognizing their work, and making sure they get back what they feel is fair.

In any case, you still have to trust them, there's no magic jail where you could put anybody to make them loyal to you.

Title: How to Protect Intellectual property violations from one's own team

Body:
I have an android app idea, I want to make the app along with a few batch-mates in my collage.

(1)  How do I make sure that these guys will not compromise the intellectual properties involved? In the sense that they will not leak out confidential information, new theories, new ideas, new features descriptions either freely on any medium or to some other company developing similar software. Also, these people will most likely have access to the entire source code (with comments) of the project, how do I make sure that in the future they will co-operate with me,

(2) will not release any part of the code,

(3) Will not freely release alpha versions containing features meant only for premium users. Also,

(4) is there way to effectively work without granting them access to the entire source code?

I am open to all kinds of answers: trust, technical, managerial - leadership, good friendship - relationship with collegues.

UPDATE: We all live in India.


问:
How to provide a ubiquitous object without including it in every parameter list
I'm writing a small C++ class, Block, to transform serialized data into a memory structure, and supply the structured data to callers through several accessor methods.  I've tried to keep its scope specific and limited.  The users of the class are very low-level - they, too, are very narrow in their focus and have as few external dependencies as possible.

This is how I've been taught to engineer things if at all possible.  By minimizing dependencies and creeping featurism, it's easier to unit test, and easier to reuse.

The problem is that my class depends upon someone else's class, Metadata.  It, too, does one very specific thing: it reads data that defines the characteristics of the data stream I'll be transforming from a database table and passes it to me.  His class checks for mySQL errors, which should be rare, and logs any errors to a Log object.

This Log object appears in all of our company's applications.  Instantiating it is a big deal - it wants Job numbers, it wants a lot of configuration information from the database that's normally put there in production by account managers using a GUI.  You have to do a lot of work before your program can instantiate the Log.  Yet this tiny, low-level class (Metadata) with one tiny task wants it to be passed in, by me.  My object certainly has no business instantiating the Log, so I have to take it as a parameter from whoever calls me.  And so forth, up the calling hierarchy.

I can understand why management wants a class to encapsulate and standardize message logging.  But the need for it to be passed to, and through, just about every method is extremely ugly, and makes testing and reuse much more difficult.

This kind of problem must be fairly common.  How can this be done without cluttering up the signature of every method you write?  Is this a legitimate case for Globals?  Is there some kind of Object Oriented approach?  And, is this a God object?

答:
It may not be immediately obvious, but you've just described a large part of the motivation behind introducing exception handling into many languages. You have a low-level component that really shouldn't impose the policy the failure uses the details of some particular logging class. Rather, Metadata's job should simply be to either 1) do its job, or 2) signal failure. Knowledge of logging should be restricted to something much higher up the stack (both figuratively and, in this case, literally) that deals with things like application logs.

So, the preferable design is that Metadata simply throws an exception if it can't do its job. At some (much) higher level, code that will invoke something that uses Metadata sets up a handler for the exception that Metadata throws, and in the handler it logs the result. Using, for the moment, C++ syntax (but the basic idea applies equally to many other languages, we get something like this:

```<code>Log log(lots,of,inputs);

try {
     Metadata metadata(input);
     Block block(metadata);
     block.write(output);
}
catch (metadata_exception const &e) {
    log(e.whatever());
}
</code>```

Result: Block and Metadata remain small, clean, and reusable. Logging happens at an appropriate level, instead of passing the Log object around to every low-level function.

Note one point though: this applies here largely because of one crucial point: you've made it clear that the logging happens only in case of an error. Throwing an exception in case of an error (i.e., you really can't continue what you were trying to do) is entirely appropriate and sensible. This pattern would not work if (for example) you were logging routine events. If (for example) you wanted to log successfully reading metadata from the database, this would not be appropriate at all.

Since you're logging failure, however, I will posit that (if available) throwing an exception is really the correct way to handle the situation -- definitely better than depending on a global Log object, having a log factory, etc.

Those are, I will posit, kludges to reduce the pain of a poorly chosen structure. They're roughly equivalent to heavy-duty bandages to minimize the blood loss after cutting off your arm. Yes, if you cut off your arm, good bandages might save your life -- but it's still a lot better to just not cut off your arm in the first place.

Body:
It may not be immediately obvious, but you've just described a large part of the motivation behind introducing exception handling into many languages. You have a low-level component that really shouldn't impose the policy the failure uses the details of some particular logging class. Rather, Metadata's job should simply be to either 1) do its job, or 2) signal failure. Knowledge of logging should be restricted to something much higher up the stack (both figuratively and, in this case, literally) that deals with things like application logs.

So, the preferable design is that Metadata simply throws an exception if it can't do its job. At some (much) higher level, code that will invoke something that uses Metadata sets up a handler for the exception that Metadata throws, and in the handler it logs the result. Using, for the moment, C++ syntax (but the basic idea applies equally to many other languages, we get something like this:

Log log(lots,of,inputs);

try {
     Metadata metadata(input);
     Block block(metadata);
     block.write(output);
}
catch (metadata_exception const &e) {
    log(e.whatever());
}

Result: Block and Metadata remain small, clean, and reusable. Logging happens at an appropriate level, instead of passing the Log object around to every low-level function.

Note one point though: this applies here largely because of one crucial point: you've made it clear that the logging happens only in case of an error. Throwing an exception in case of an error (i.e., you really can't continue what you were trying to do) is entirely appropriate and sensible. This pattern would not work if (for example) you were logging routine events. If (for example) you wanted to log successfully reading metadata from the database, this would not be appropriate at all.

Since you're logging failure, however, I will posit that (if available) throwing an exception is really the correct way to handle the situation -- definitely better than depending on a global Log object, having a log factory, etc.

Those are, I will posit, kludges to reduce the pain of a poorly chosen structure. They're roughly equivalent to heavy-duty bandages to minimize the blood loss after cutting off your arm. Yes, if you cut off your arm, good bandages might save your life -- but it's still a lot better to just not cut off your arm in the first place.


问:
Y combinator and tail call optimizations
The definition of a Y combinator in F# is

```<code>let rec y f x = f (y f) x
</code>```

f expects to have as a first argument some continuation for the recursive subproblems.
Using the y f as a continuation, we see that f will be applied to successive calls as we can develop

```<code>let y f x = f (y f) x = f (f (y f)) x = f (f (f (y f))) x etc...
</code>```

The problem is that, a priori, this scheme precludes using any tail call optimization : indeed, there might be some operation pending in the f's, in which case we can't just mutate the local stack frame associated with f.

So :

on the one end, using the Y combinator require an explicit different continuation than the function itself.

on the othe to apply TCO, we would like to have no operation pending in f and only call f itself.

Do you know of any way in which those two could be reconciled ?
Like a Y with accumulator trick, or a Y with CPS trick ?
Or an argument proving that there is no way it can be done ?

答:
Do you know of any way in which those two could be reconciled?

No, and with good reason, IMHO.

The Y-combinator is a theoretical construct and is only needed to make lambda calculus turing complete (remember, there are no loops in lambda calculus, nor do lambdas have names we could use for recursion).

As such, the Y combinator is truly fascinating.

But: Nobody actually uses the Y-combinator for actual recursion! (Except maybe for fun, to show that it really works.)

Tail-call optimization, OTOH, is, as the name says, an optimization. It adds nothing to the expresiveness of a language, it is only because of practical considerations like stack space and performance of recursive code that we care about it.

So your question is like: Is there hardware support for beta reduction? (Beta reduction is how lambda expressions are reduced, you know.) But no functional language (as far as I am aware of) compiles its source code to a representation of lambda expressions that will be beta reduced at runtime.


问:
Good Practice : Storing variables and classes names in database for direct call
I would like to know if this is a good practice to store variables and classes names in database to use let users accessing them.

For instance users may create entries in database's table in which they can insert a program's function name that would executed when the program will read it.

I find it is a dangerous practice since users may execute or access any data of the program, but I've been told it's a quite common practice in languages with introspection like Python.

Moreover, i was also suggested to have field in a table that would store another table field's name, to create somehow a dynamic foreign key.

I personally find both practices very bad since in first case there is no more separation between user data and program data, and for the second case there is no separation between structure and data in the database.

Can you please confirm me these practices are discouraged or tell me I'm wrong and suggest me a way to approach them in a safer way.

Thank you.

答:
This has nothing to do with data bases in particular. A data base is merely a device for preserving assets of your program across different invocations cheaply and reliably. The question is: is it sensible to treat the names rather than the contents of object attributes, classes, etc. as assets in your program or not?

If it is, then saving and restoring them from a data base is the obvious thing to do when you need persistence. If it isn't, then there may be obvious problems with the practice, but those aren't related to persistence, they would be just as grave when applied to the architecture of your application in the first place.

(I'm exaggerating slightly here. Saving data to persistent storage inevitably introduces the problem of legacy data that must be handled by new versions of the code, i.e. by code that isn't the same code which created them. Data base schemas are notoriously long-lived and often not under your complete control, because they must be shared with other applications in your business. Therefore, storing data persistently tends to amplify any architectural problems your code has. Nevertheless, the main point is that reflection may or may not be appropriate, but not because it causes weird table or schema elements.)


问:
Will high reputation in Stack Overflow help to get a good job?
In a post, Joel Spolsky mentioned that 5 digit Stack Overflow reputation can help you to earn a job paying $100k+. How much of that is real?

Would anyone like to share their success in getting a high paid job by virtue of their reputations on Stack Exchange sites?

I read somewhere that, a person got an interview offer from Google because a recruiter found his Stack Overflow reputation to be impressive. Anyone else with similar stories?

答: Yes. Maybe less so now, but more so in the future. I'm gainfully employed, but I have had 4 google interviews, and all the front line HR people asked me questions that they could only have learned if they googled me and my contributions in other sites (perhaps the thing that hurts stackexchange is the alias - rather than a direct name response). It's only a matter of time before they make the leap to asking for aliases on sites like stack exchange.</p>

OwnerDisplayName: aargau


问:
Why don't companies ship multiple modules within a mobile app? Are there concerns about tight coupling?
Preface: My question does not exclusively pertain to Google and it doesn't exclusively pertain to iOS. I'm only using Google and iOS as examples because they are familiar to many. I could have just as easily used 'Company X', apps 'A', 'B', 'C', 'D', and 'E', and 'Android', but I wanted to keep my question rooted in the real world with a tangible example.

In the iOS app store, Google has many apps. At a glance, I can see 'Google Search', 'Google+', 'Google Maps', 'Google Earth', and 'Gmail'.

But I wonder - Why didn't Google simply create a 'Google' app which can provide all of the functionality that these five apps provide? The black menu bar at the top of each Google webpage makes this possible on the web; so why don't they make this possible by way of a menu button at the bottom of one "global" Google app?

Is Google concerned about tight coupling between the apps?

Is Google concerned about tight coupling between the teams that develop the apps?

Is Google concerned about app size?

Is Google concerned about the memory footprint or CPU load that such a monolithic app might incur when it is loaded?

[Not a rant. Merely playing devil's advocate.]

In spite of many advantages, some iOS critics say that multiple pages of apps leave the iPhone and the iPad feeling "cluttered". This is particularly relevant to my question because it seems a bit much to expect a user to know about (and manage) so many Google mobile offerings. From a product standpoint, and arguably a usability standpoint, it seems like it would be wise to ship a single app.

If you're curious, I own an iPhone and a Nexus 7; so I'm not wedded to either of the two major mobile platforms.

And I have a real problem to solve here - Whether to bundle multiple apps inside of one large app, or to distribute separate bits of functionality in multiple apps.

EDIT: In response, to @MichaelT's comment

While there is indeed a 2GB size limit for apps, the size of your sandbox is only limited by the remaining capacity on the device.

答:
At the risk of going against all the other posted opinions, I think making a Google mobile app with everything* integrated but out of the way would be a great idea!

A lot of their software can be applicable to a single user account. I personally use Gmail, Google Search, and Google Drive the most. These apps are separate apps but they are integrated together. If I am already on one of those three apps in the browser and need to go to the other one I find the top navigation bar to be the best way to switch between apps.

In Programmatic Thinking & Learning Refactor Your Wetware, Andy Hunt states that multitasking and context switching takes a toll on productivity and this includes switching between apps to get things done.

Do you know what Alt-Tab (or Command-Tab on a Mac) is called? It's a
  context switch.

Emacs is a good example of a single powerful program with a huge variety of functionality and purposes. Look at its success, it's been around for 37+ years and it is still a very popular editor. From Emacs I can check and send email, edit any file, run shell commands, browse the web, schedule events and todos, etc. I can do all this without switching contexts.

Google, likewise, could mitigate context switching by linking the mobile apps together or they can avoid it completely by making a Google App.

*If productivity is not the goal of the app or the apps are completely unrelated then I wouldn't see a good reason to combine apps into a single product. In Google's case a lot of its apps are productivity-oriented.


答:
i'm convinced that you won't succeed by founding your business endeavour on open distrust towards your colleagues - remember, you actually need them to build the system, otherwise you wouldn't be concerned with the issue your question adresses.

i'm also convinced that you focus on the wrong aspect wrt intellectual property: while it's correct that the source code embodies your product the edge of your fledgling company will be the brains of the members at the founding stage. the more you suggest dishonorable behaviour or outright violation of the law amongst your coders, the less likely you will attract gifted personnel (or if you do, the easier you'll alienate them). but the more gifted your team the better, in particular as your product will probably evolve (possible far from the inchoate concept) to meet customer demand - so a source code snapshot might be less valuable than it seems at first glance.

a constructive remark at last:
source code, even in high-level languages, can be hard to understand. even more so, if comments and documentation are sparse and incomplete. your best protection might be

a gifted team

component-wise development

a coding style of 'no comments'.

it violates basic tenets of sw engineering but will protect you even if a member of your team does leave you: as he will naturally have specialized in only some of the components of your application, the disclosure impact will be somewhat mitigated.

disclaimer:
i'm no founder and have not worked in india, so take the ideas with some grain of salt.


问:
Multiple Data Types for Single Variable in C
I am trying to implement basic cons, car and cdr of SCHEME in C. I have made a simple program that allows me to cons two integers as shown in the main program. However, I want my program to be able to cons a 'consed object' with a digit as well as cons a 'consed object' with another 'consed object' as shows below:

(cons 2 3)

(cons 2 (cons 2 3))

(cons (cons 2 3) (cons 2 3))

Since the limitation arises because the data in the struct is of type int, is it possible to have a variable accept multiple data types in C? If yes, how? If not, is there another way to deal with this issue?
Here is my code:

```<code>#include <stdio.h>
#include <string.h>

typedef struct cons_object {
int data;
struct node* next;
} cons_object;

cons_object* cons(int x, int y )
{
cons_object* car = NULL;
cons_object* cdr = NULL;
car = malloc(sizeof(struct cons_object));
cdr = malloc(sizeof(struct cons_object));
car->data = x;
car->next = cdr;
cdr->data = y;
cdr->next = NULL;
return car; /*returns the pointer car*/
}

int car(cons_object* list) /*takes in a consed object*/
{
cons_object* car = list;
int y;
y = car->data;
return y;
}

int cdr(cons_object* list)
{
cons_object* cdr = list;
cdr = cdr->next;
int z;
z= cdr->data;
return z;

}

int main ()
{
int y = car (cons(33,42));
printf("%d\n",y);
int z = cdr (cons(3,4));
printf("%d\n",z);
return 0;

}
</code>```

答:
Make it a void *.  Then it can point to anything.  Memory management is up to you.

This will result in not having any type checking.  If you go down this path, see http://libcello.org/ for what is possible.  (But if you want to go down this path, why are you writing in C?)


问:
Do you throw an argumentexception or argumentnullexception from private methods?
I was just reviewing some code I wrote a while back, and can see that I have a couple of private methods that throw argumentnullexceptions and/or argumentexceptions if there are issues with the methods parameters.

I guess my rationale is that helps future proof the application if someone attempts to "misuse" the method in future. However, given it is a private method and the people who are likely to call this method can see the associated comments and code, it is just unnecessary to throw this. It certainly doesn't hurt to have them, although it does add clutter.

My feeling is that these exceptions are generally more useful on something like a API that is going to be exposed publically.

答:
Consider the following structure:

Internal logic: This function assumes to be called with correct parameters and therefor uses asserts to verify preconditions, postconditions and invariants to check your inner logic.

User interface wrapper: This function wraps the internal function and uses InvalidArgumentExceptions to handle wrong values and to tell the user to correct his inputs:  Assert(x).hasLength(4);,  Assume(y).isAlphanumeric();, Assert(z).isZipCode();, Assume(mailAdress).matchesRegex(regex_MailAdress);, Reject(x).ifEmpty();, etc.

Batch interface wrapper: This function wraps the internal function and uses logging, validity markings and statistics to handle wrong values without interrupting some long-running task. The markings could be used later by someone checking and cleaning the result-database.

Command line interface wrapper: this function wraps the internal function and asks again for the last input.

You should use both - asserts and exceptions - in different methods for different tasks. You should separate internal logic from parameter checking.
Compare it to the separation of  Model, View, Controller.