答:
Here are some things that occurred to me after writing this question:

A development team often sits within a larger organisation which has its own policies and practices (I'm not talking about waterfall-style things like "must have a complete project requirement specification before writing code" which are incompatible with Scrum!). There may be requirements for how or when deployments have to be done, coding style guides or coding standards, etc. - some of these could be guidelines, some of them could be "must-fulfill" requirements. Then, realistically, I think Scrum is about the team deciding how to do things within those constraints and guidelines (and where it feels it is necessary, e.g. to remove impediments, trying to persuade the organisation to change them) but not about a team unilaterally ignoring them. Or it shouldn't be, anyway.

A development team never has an absolutely unlimited budget. If a design or architectural decision has budget impact (e.g. acquiring new servers or VMs for a distributed NoSQL database, or longer initial development time or a risk of that), it may need to be signed off by someone with authority on budgetary matters. Scrum cannot change that.

Training, or even just opportunities for experienced developers to chat with an inexperienced team, can help to avoid beginner mistakes such as "God classes".

Code review, pair programming, or even just working on each other's code (which should be a normal event due to the cross-functional aspect of Scrum), can uncover problems early. Even just looking at someone's code that is not your own can make you more objective about the impact of design decisions. Many programmers love to poke holes in other people's work, let's take advantage of that tendency ;)

Title: Scrum decision making versus maintainability and development time?

Body:
I appreciate that this question may be controversial. In a sense, it is the flip-side of the question "Business trying to make technical decisions".

In Scrum, the development team is supposed to be collectively responsible for making design and technical and code-level decisions, to fulfill the customer requirements. There is a division of responsibility and power between the product owner, who defines and prioritises the stories by communicating with stakeholders, and the team, who decide how to implement the stories.

I think this is motivated by the belief that, since developers are intimately familiar with the code they have written so far, and all the information they have memorised or noted about the project, and they will face the consequences of poor decisions when they have to modify the code in future, they are best placed to make design decisions. And if in hindsight they realise they made a bad decision, it will be a very valuable learning experience for them, and they won't be able to blame management for what went wrong. In theory, I agree with all this. But (to kind of play devil's advocate) I can see several situations in which following this principle to the letter could be a bad idea:

The development team are mostly either temporary contractors, are (unbenownst to others) intending to jump ship, or are going to be made redundant after shipping this project, or are going to move to another project and there is an entirely separate team which will do "code maintenance". (A good example of this might be: a typical outsourced government computerisation project.) So, for any of these reasons, the team mostly aren't the people who will be doing the actual maintenance.

Or, the development team are all inexperienced developers who don't really have a clear idea of the maintainability problems that can be caused by slipshod development practices or poor design decisions. While they have an incentive in theory to do the right things, the incentive isn't working yet because they haven't been burned enough times (or they haven't acknowledged the connection between sloppy coding practices and getting burned).

The development team like making big mistakes and working crazy hours to fix or work around them because (a) they are workaholics, (b) they like wasting time writing boilerplate code or using some bad old framework because it gives them a sense of job security, or (c) it makes them look like or feel like heroes.

The team like to endlessly bikeshed, or discuss endless different permutations of ideas, or add "internally-visible features" which are low-value, while the business really needs them to deliver value faster, and come on, good enough is good enough!

There may be others in the organisation who could provide a variety of useful inputs into design and technical decisions: More experienced developers; Polyglot developers; Specialists, including DBAs (who may not necessarily be in the scrum team); Managers, who may be cynical and may have seen over-ambitious or wrong-headed architectures go awry too many times.

But it's not just about getting input from people with valuable experience. More than this, isn't it fundamentally sometimes necessary for management (at any level) to be able to say "No, this way of implementing it would be a bad idea. Do it this way instead", or at least "No, you can try that later if there's time, but do it this simpler way initially"? It seems to me that Scrum is too idealistic in this respect. I know that this does happen, obviously, but to say that because of this interference "your organisation is not doing Scrum" suggests that "doing Scrum" is not desirable in such cases!


问:
Scrum decision making versus maintainability and development time?
I appreciate that this question may be controversial. In a sense, it is the flip-side of the question "Business trying to make technical decisions".

In Scrum, the development team is supposed to be collectively responsible for making design and technical and code-level decisions, to fulfill the customer requirements. There is a division of responsibility and power between the product owner, who defines and prioritises the stories by communicating with stakeholders, and the team, who decide how to implement the stories.

I think this is motivated by the belief that, since developers are intimately familiar with the code they have written so far, and all the information they have memorised or noted about the project, and they will face the consequences of poor decisions when they have to modify the code in future, they are best placed to make design decisions. And if in hindsight they realise they made a bad decision, it will be a very valuable learning experience for them, and they won't be able to blame management for what went wrong. In theory, I agree with all this. But (to kind of play devil's advocate) I can see several situations in which following this principle to the letter could be a bad idea:

The development team are mostly either temporary contractors, are (unbenownst to others) intending to jump ship, or are going to be made redundant after shipping this project, or are going to move to another project and there is an entirely separate team which will do "code maintenance". (A good example of this might be: a typical outsourced government computerisation project.) So, for any of these reasons, the team mostly aren't the people who will be doing the actual maintenance.

Or, the development team are all inexperienced developers who don't really have a clear idea of the maintainability problems that can be caused by slipshod development practices or poor design decisions. While they have an incentive in theory to do the right things, the incentive isn't working yet because they haven't been burned enough times (or they haven't acknowledged the connection between sloppy coding practices and getting burned).

The development team like making big mistakes and working crazy hours to fix or work around them because (a) they are workaholics, (b) they like wasting time writing boilerplate code or using some bad old framework because it gives them a sense of job security, or (c) it makes them look like or feel like heroes.

The team like to endlessly bikeshed, or discuss endless different permutations of ideas, or add "internally-visible features" which are low-value, while the business really needs them to deliver value faster, and come on, good enough is good enough!

There may be others in the organisation who could provide a variety of useful inputs into design and technical decisions: More experienced developers; Polyglot developers; Specialists, including DBAs (who may not necessarily be in the scrum team); Managers, who may be cynical and may have seen over-ambitious or wrong-headed architectures go awry too many times.

But it's not just about getting input from people with valuable experience. More than this, isn't it fundamentally sometimes necessary for management (at any level) to be able to say "No, this way of implementing it would be a bad idea. Do it this way instead", or at least "No, you can try that later if there's time, but do it this simpler way initially"? It seems to me that Scrum is too idealistic in this respect. I know that this does happen, obviously, but to say that because of this interference "your organisation is not doing Scrum" suggests that "doing Scrum" is not desirable in such cases!

答:
It sounds like the familiar Architecture and Technical Debt debate your having.
You don't have any mention of an "Architect Role", which may be part of the problem For some great resource on "Software Architects" see: http://www.codingthearchitecture.com/authors/sbrown/. Simon Brown has lots of good ideas trying to address many of the issues your currently facing.

Seeing you're London based, there is a good Software Architecture conference in London annually. See a review I've written about the value of the conference. Software Architecture Conference – London 2012 by Jamie Clayton

I would also keep an eye on software decision for "resume padding". Many short term developers wanting to use a technology combination based on no business reason other than to improve there own skills.

After many years of working (fighting) with business decision makers and accountant/financial staff making business decisions (tight wads), that software maintenance and support is very important and should be factored into corporate budgets because it's easily becomes 80% of the cost of running the software, while the initial Scrum/Project represents 20% over the lifetime of a corporate software solution.

Pitch to the business an in-house Maintenance/Licensing contract for any corporate software, as 20%-30% of the upfront project cost per-annum. This is what any commercial software vendor would charge as a minimum.  If the business will not accept those costs as part of the Cost/Benefit, then you should advise against the project (let them make the fatal decision).

ContentLicense: CC BY-SA 3.0


问:
Is the Product Owner also a developer on your team?
I'm confused about the PO's responsibility here. I was a developer on a Game Feature Team, but  also a PO. The daily work of the developer is almost full time, so I have to work over time to take care my PO duty, and the responsibility of PO seems to be against developer's thoughts.

As a PO, I will chose more features next sprint. Otherwise, I will tell myself not to do so, because I'm a team member to develop those features. This situation makes me confused, so I want to hear some ideas from you guys.

I'm a new to Scrum and Game Dev (about 1 and half year), and also new to here and English.

答:
I understand the general balance problems between the two roles, but what I don't understand are your specific concerns.

Development is only a full time role if you make it so. If you count yourself only as 50% during sprint planning (when counting up all developer-hours/days available), you should have plenty of time left for your PO duties.

OwnerDisplayName: Charlie


问:
Distribution of Event Listeners in a Distributed Service Oriented Architecture
I have a service architecture composed of services that service common areas of the application. Examples of services would be:

AccountService (manages client accounts in the system)

BillingService (bills clients for products that are configured)

UserService (manages user and groups under a given client)

NotificationService (sends notifications via email/SMS/push/any method when certain events happen)

I have an ActiveMQ cluster where I push events to act on...which leads to the question...

Where is the right place to put a message listener that reacts to an event for the purposes of sending a notification? A simple example would be: "I want to notify the account owner via e-mail when a new user is added to their account."

Should this listener be in NotificationService (which is intended to be highly generic), or in UserService (where the action is being performed), or in a separate service entirely which acts as a sort of router?

答:
A router service has two concerns.

It would end up with an infinite number of operations on a ratio of 1:1 with messages within the system and become unwieldy.

The router service must know about every other service.

By adding a listener within each service you limit the listeners only to their responsibility to the service. Following your logic it would make most sense to add the operation to the UserService (which may call the NotificationService to perform the actual work).


答:
One of the keys to Agile development (and Scrum in particular) is a shortened feedback loop.  That is, the development team are expected to deliver working software every two to four weeks.  If, after one or three sprints, the team is not delivering, management knows there is a problem and can change direction.

Take your scenarios:

Contractors/disinterested team members.  Either the team isn't delivering (get new contractors STET) or they are delivering unmaintainable software.  This should come into evidence fairly quickly if they are not producing repeatable (automated!) tests that demonstrate the software actually works, and if they start panicking when a new user story mandates the reworking of code from an earlier sprint.  Scrum does not negate the need for IT governance, and this is especially so when working with contractors.

Inexperienced developers are an issue no matter what the project.  The solution (no matter what the methodology) is to put at least one experienced programmer on every team.  Again, it should be evident quickly that the team doesn't know what it's doing.

Masochists/Heros.  Again, the requirement of delivering working software every several weeks should make it evident that the team is wasting time.  If the team starts working stupid hours, don't let them take on as many stories the next sprint.

Bikeshedders  Not delivering==problem that is solvable.

A command and control structure on projects doesn't really handle these issues any better.  It cannot instill the sense of ownership needed for problem 1.  It requires the involvement of experienced developers (which is the solution for item 2 either way). It plays into the masochist/would-be hero's hands, unfortunately resulting in high-risk situations and shoddy software.  And, it probably won't show and solve the team's inability to make technical decisions any faster than Scrum does.

Scrum is a fail-fast methodology (or framework, anyway).  That's its biggest strength.


答:
This is why it's not enough to focus on Scrum or technology -- talent selection is in part what makes or breaks the project.  No methodology, supervision or policies can make up for lack of talent.

These four examples examples are exactly why it's important for the team to include some good senior developers who have experience delivering complex projects, and who are committed (through personal interest and financial incentives) to ensuring that the project stays on track. The team does not have to be comprised entirely of experienced devs, just needs to have them in lead positions.

In case of outsourced project, it is good to be sure that both the outsourcing team has appropriate skills and experience, as well as having experienced developer internally who would monitor the output of the outsourced team, possibly doing a lot of hand-holding, writing specs, and reviewing the code (when source code is part of the delivery).


问:
Difference between event loop and system calls/interrupts
When you create programs (like a socket server) that are designed to run on an operating system, such as Ubuntu, frameworks like Qt for C++ use something called a main event loop:

```<code>app = new QCoreApplication(argc, argv);
int rc = app->exec()
</code>```

Now programming language like C or C++ enable a program to make system calls through built-in functions, like fork() or pthread_create() and use software interrupts to change kernel mode. For example, the program can request use of the kernel by means of a system call in order to perform privileged instructions, such as process creation or input/output operations. Other examples are open, read, write, close, wait, execve, fork, exit, and kill. All this can be achieved within C/C++ directly without an event loop.

So what's the purpose of the event loop?

答:
Comparing event loop to system calls, is similar to comparing apples to.... cars and not just orange cars.

System calls are used as part of your normal, structured control flow.  You do X, Y, system call then Z.  As you pointed out, the purpose of system calls is to give your app to subsystems which are managed by the kernel.  Since those subsystems are shared/accessed by multiple processes, you must cross the boundary from user into kernel space in order to work with them.

Event loops, on the other hand live completely in your user space. They are the basis of an Event Driven Programming (EDP), which is very common GUI applications but also has uses in many other areas.  Instead of having one control structure that does "X, Y, sleep, Z, system call..." in EDP you define small snippets of code (i.e. event handlers) and their job is to respond to particular events.  Event loop is what dispatches those events to their respective handlers, at the most basic level, it is nothing more than a queue and a lookup table with function pointers.

Since GUI applications are by their nature event driven (i.e. user clicks here and there), event loops are just about universally used to drive them.  One reason for using events in a GUI is let's say you want something to blink every 2 seconds.  If you had a non-GUI app, you could implement a simple loop with sleep(2), but if you call sleep() in a GUI, your application would freeze since the loop would no longer respond to mouse/keyboard clicks from the user.  The way around it, would be to create a timer that fires an event every 2 seconds. This way the loop will continue to dispatch all other events and every 2 minutes your timer handler would be invoked to change the color of whatever it is you are blinking.

To clarify what an event loop is (in pseudo code):

```<code>   while(true) {
      event = GetEvent()  // will sleep until next event arrives
      DispatchEvent(event)
   }
</code>```

This can run on just about any thread, but would typically be on the main one that started the app.  Inside DispatchEvent, you simply have a lookup map, that maps event types (e.g. an int) to one or more event handlers (function pointer, interfaces pointers... etc) registered to listen for that event.

Body:
Comparing event loop to system calls, is similar to comparing apples to.... cars and not just orange cars.

System calls are used as part of your normal, structured control flow.  You do X, Y, system call then Z.  As you pointed out, the purpose of system calls is to give your app to subsystems which are managed by the kernel.  Since those subsystems are shared/accessed by multiple processes, you must cross the boundary from user into kernel space in order to work with them.

Event loops, on the other hand live completely in your user space. They are the basis of an Event Driven Programming (EDP), which is very common GUI applications but also has uses in many other areas.  Instead of having one control structure that does "X, Y, sleep, Z, system call..." in EDP you define small snippets of code (i.e. event handlers) and their job is to respond to particular events.  Event loop is what dispatches those events to their respective handlers, at the most basic level, it is nothing more than a queue and a lookup table with function pointers.

Since GUI applications are by their nature event driven (i.e. user clicks here and there), event loops are just about universally used to drive them.  One reason for using events in a GUI is let's say you want something to blink every 2 seconds.  If you had a non-GUI app, you could implement a simple loop with sleep(2), but if you call sleep() in a GUI, your application would freeze since the loop would no longer respond to mouse/keyboard clicks from the user.  The way around it, would be to create a timer that fires an event every 2 seconds. This way the loop will continue to dispatch all other events and every 2 minutes your timer handler would be invoked to change the color of whatever it is you are blinking.

To clarify what an event loop is (in pseudo code):

   while(true) {
      event = GetEvent()  // will sleep until next event arrives
      DispatchEvent(event)
   }

This can run on just about any thread, but would typically be on the main one that started the app.  Inside DispatchEvent, you simply have a lookup map, that maps event types (e.g. an int) to one or more event handlers (function pointer, interfaces pointers... etc) registered to listen for that event.


答:
You started with mentioning Qt, it's a good starting point. Qt is a GUI library. A GUI usually works with kinds of external events which could be predicted, because originate in user's activity. Graphic environments like Windows (Microsoft), X Window, Mac, all current smartphone/tablet environments, etc. allow user to make essentially any input he could "send", as pressing keys (not only on keyboard), mouse events, touchscreen gestures, etc.

If a program is written sequentially, processing all such events becames, saying colloquially, an unbearable level of both headache and butthurt at the same time. Instead of, organizing a program as event driven solves this. There are event generators, dispatcher and event processors. If a mouse key is pressed, the corresponding event is sent to a widget currently pointed. No complex code is needed in that case to provide matching against the current visible widget and window set; OTOH, if this code had written, it would be practically identical to the dispatching code in event loop based engine.

Similarly, if I write an application which supports 100k clients over network connections, I won't iterate all them to check whether new data has arrived. I will add their listenings to event engine and simply wait any incoming events in callbacks. It's not something artificial - it's the consequence of natural evolution of dealing with multiple event sources, provided "event" here is an abstract definition of something that program shall react to.

So, event loops and, in general, event-based programming isn't a thing which contradicts to all techniques you have mentioned; no, it's just a level upper than they are. Event handlers can then use file I/O, socket I/O, etc.

Title: Difference between event loop and system calls/interrupts

Body:
When you create programs (like a socket server) that are designed to run on an operating system, such as Ubuntu, frameworks like Qt for C++ use something called a main event loop:

```<code>app = new QCoreApplication(argc, argv);
int rc = app->exec()
</code>```

Now programming language like C or C++ enable a program to make system calls through built-in functions, like fork() or pthread_create() and use software interrupts to change kernel mode. For example, the program can request use of the kernel by means of a system call in order to perform privileged instructions, such as process creation or input/output operations. Other examples are open, read, write, close, wait, execve, fork, exit, and kill. All this can be achieved within C/C++ directly without an event loop.

So what's the purpose of the event loop?


问:
Moving a multi-GB SVN repo to Git
Currently my company has a Visual Studio solition in an SVN repo that's organized as follows:

```<code>SolutionFolder (~3.5 GB)
|-> SolutionName.sln
|-> .. Some source code folders... (~250 MB)
|-> ThirdParty (~3 GB)
|-> Tools
    | -> Tool1
    | -> Tool2
</code>```

Tool1 and Tool2 are build independently (have their own solutions), but produce executables that are used in the main build.  ThirdParty folder contains all dependencies for the project, including some pre-compiled 100+ MB .lib files and large libraries like boost.

It's convenient to have it all in one SVN repo so that (1) developer has to do only one check-out, and (2) we don't need to keep track which versions of dependencies we need for each version of the build.  On the flip side, it takes a while to check out this repo.

What would be the best way to move this project structure to git?  Presumably it's best to exclude ThirdParty and possibly Tools from the main repo, but we'd like to keep ThirdParty easily downloadable in one step, and we like it versioned (and version mismatches between main repo and ThirdParty/Tools would be bad).

At this point I'm not interested in preserving history, just in figuring out how to organize such project.

答:
The entities that you turn into git repositories are necessarily the entities that you version and branch; if SolutionFolder/Tools/Tool1 corresponds to one such thing, that's the level of entity. This is because git regards the entire state of the directory tree to be the versionable entity, whereas with svn it is possible (even if not a good idea) to have a trunk, branches and tags anywhere within the tree.

Derived artefacts should not be kept in the repository, nor should external libraries. There are better ways to handle those. (If you're working with Java, consider using a private Maven repository; they're comparatively easy to work with, and integrate nicely with many other things.)

If you're used to a workflow that has everything in one repo for ease of checkout, consider having a script that sets things up instead.

Title: Moving a multi-GB SVN repo to Git


问:
What is the role of an Information Architect?
I've heard this term bandied about, especially in reference to web development, but I'm having trouble getting a clear understanding of what an Information Architect actually does.

Any ideas what their role or deliverables would be?

答: As I understand it, an Information Architect decides how information will be organized and presented on a web site.  This would include navigation, aggregation, presentation (more what is presented than how) and access control (including security and filtering).  Think of them as responsible for "content design", as opposed to "site design".

ContentLicense: CC BY-SA 2.5


问:
Is there a guide for software development to design efficient hotkeys for actions?
I don't know how to word this easily but basically the software I am writing has a ton of actions and I want to assign hotkeys to every one of them so power users can work super fast.

First off they are not actions related to the application itself, i.e. Quit, Maximize Window, About, Preferences, etc. But rather actual operations you perform on the data set.

It's not exactly the same but closest example I can give is the Nuke compositor, where each action is represented by a node. So things like Blur, Sharpen, Add, Color Correction, Keylight, etc.

But since the number of nodes are over 500, I don't know how to create easy to remember hotkeys that do not use every modifier key combination.

Is using 2 key combo, i.e. CC for Color Correction the best way?

Are there resources on this subject? Basically maximizing the use of hotkeys to take working speed to the max without having to remember 1000s of key combinations.

答:
I don't know if this method applies well to your application, but since you have many commands to assign, you can consider using something like Quick Access from Eclipse.

This way, the user can reach the command fast and easily only with the keyboard.

Example:
https://www.youtube.com/watch?feature=player_detailpage&v=y8-PSiwgOl4#t=46


问:
Thoughts on Development using Virtual Machines
I'll be working as a development lead for a startup and I've suggested that we use VMs for development.  I'm not talking about each developer having a desktop with VMs for testing/development, I mean having a server rack where all VMs are managed and have the developers work from a microPC (ChromeOS anyone?) locally, or even remotely from their home computer.

To me, the benefits are the fact that it's extremely scalable, cheaper in the long run, easier to manage and that we utilize the hardware its maximum potential.  As for cons, I can't think of any particular showstoppers other than we'll need someone to setup/maintain said setup.

I was hoping that some of you might of had a similar setup at your place of employment and be able to weight in with your opinions.  Thanks.

答:
TL;DR: I've done it at multiple jobs and I now prefer it.

Cost is the wrong reason to focus on.  Here are some better ones.

Reasons

Platform consistency in the different environments (dev, test and production).

Why: It completely eliminates a defect vector, defects from platform differences in different environments.

Allows system changes like upgrades to occur first in development vms, be verified, roll up to test, be verified, and roll into production; all much easier with development (and test) vms.

Why: Control.  I can snapshot, rollback, identify the deltas, do the change on one server and propagate a success by simply duplicating the vm, etc.

Sometimes the systems you develop against are only available on a secured network.  Alternatively, the server your software will run on may only have limited access or different network characteristics.

Why: The development VM can be on the VLAN that has access to the locked down system or service.  Alternatively if the dev server has the same limited access as the test and production server, there is never a question of accidentally coding a requirement on a network characteristic or access that won't be available.

Challenges

The number one challenge is remote development, especially if you have to go through a gateway or jump server.  It makes it difficult, especially if the developers are not well rounded (they have some system engineering knowledge, networking knowledge, etc).

There are many variations of remote development, but they usually boil down to 2 main differences.

Run your development tools in the remote environment and use protocols like RDP clients, remote X11 clients, etc.

Run your development tools locally and use protocols to transparently sync or execute on the remote server, often using ssh as the transport layer.

Tools

There are tools that will help with remote development, and there are IDEs that facilitate it.  You will have to investigate to what degree it is capable of remote development, many are not without running on the same server the code is being developed on.  However there are other tools.

Secure Shell: Most successful remote development setups use ssh to a greater degree, using passwordless logins (using key authentication), transparent multihops (solves the jump server issue) and other configuration options to improve response time.  Note: I've always had issues using non-OpenSSH implementations of SSH.

GNU Screen/TMUX: Terminal multiplexers.  Screen is the granddaddy of them and is still going strong, but I think most people have started switching (or even starting) on TMUX.

Vim/Emacs: The old guard, but both work great for remote development in different ways.  It's Vim so all it needs is a shell, while Emacs can run locally and use TRAMP for remote development.


答:
At the system level its all the same. You waggle a mouse, press a key, stroke the screen, receive a wireless packet, this triggers a system level interrupt, which executes the chunk of code assigned to the interrupt.

However at a higher level there are two distinct programming styles commonly used.

The "callback" --> you assign a chunk of your code to be run when an event occurs. As several events may overlap you need your program to be multi-threaded and your event handlers to be thread-safe. The advantage is a more responsive program, the disadvantage is the extra effort to ensure thread safety and the impossibility of testing all possible combinations of events.

The "event loop" --> the chunk of code assigned to an event merely records the event in a table/stack/list. The main thread of your program then scans the list for events and runs the necessary code to process the event. The disadvantage is a less responsive program as you need to completely finish processing one event before going on to the next, the advantages are simpler code as all events are processed by a single thread, and, the possibility of complete test coverage.


问:
Two months in my new job, still having trouble learning a new codebase. How can I improve?
I'm a self-taught programmer. Up until now I haven't had too much problems building things I have wanted to. Historically, given an issue, especially one I have caused I haven't had much of a problem figuring it out. This all changed about two months ago, when I was offered my first position at a company whom I became acquainted with after a pull request to a framework they use.

I relocated for the position and I really like the environment, it's a small team of about ten people, and from what I can tell they all seem to be incredibly talented. They gave me a pet project to do in which I had mostly full autonomy over. They stressed that they dont expect developers to become entirely productive and profitable until about the 3-6 month marks and that this project would help them understand where I'm at as a developer. It felt great and after a month I was put on one of their bigger projects on one of their most longstanding contracts.

After switching to this project I felt kind of overwhelmed, it is a LARGE codebase where changes are very visible to our clients clients, as it powers a number of sites. It is also a very complex codebase, while I attribute a lot of my hardship to my lack of experience it was originally a rescue project, syncs everything between two seperate frameworks and has a number of models that do thing I cannot given my experience understand, has no documentation, and a test coverage of 85%. I was originally tasked with making a few small changes, things like implementing honeybadger notifications on mail delivery failures, or rewriting minitest tests to rspec specs.

Then I was tasked with upgrading one of the frameworks that the project depends on. This has taken me an abnormally large amount of time, and I was retasked to something else until one of the senior developers comes back from holidays to act as a support system during the process. The task I was reassigned to turned out to be giving me an equally large amount of trouble.

I had a sit down with my employers and talked to them about this. They stated that it's normal given my experience and that I currently meet their expectations. However, this is the first time in my life I really could not do what I set out to in any amount of reasonable time. Is this a feeling that is shared among others, is it a normal occurrence?

What would be the expected amount of time to become acquainted wit a large codebase of say 50,000 lines? Are there any other practices that I may not know about that could help me become familiar with a codebase faster?

答:
Studies have shown that people who go to sleep immediately after studying have twice the recall rates of those that have distractions between studying and sleep.

It's amazing really.

Read the stuff just before bed, and be sure to not allow any other distractions between your reading and bed time.  Fill your brain full of facts until you can't hold any more, and then hit the sheets.

Using this technique I became certified in 4 languages one winter in a span of only a few months, (i.e. I was able to pass a certification test in these languages).  In one of the languages I was able to hit top of my class because of almost near perfect test results.  I don't think I ever could have done this without this learning technique.

I read this many years ago in a book on cognition, and it has served me well over the years.

Sad that more people aren't taught this at an early age.


答:
I.A.I. definition

Information architecture is defined by the Information Architecture Institute as:

The structural design of shared information environments.

The art and science of organizing and labeling web sites, intranets, online communities, and software to support findability and usability.

An emerging community of practice focused on bringing principles of design and architecture to the digital landscape.

Title: What is the role of an Information Architect?

Body:
I've heard this term bandied about, especially in reference to web development, but I'm having trouble getting a clear understanding of what an Information Architect actually does.

Any ideas what their role or deliverables would be?


答:
The argument is not to let an incompetent team manage itself? Why would anyone want to put a Scrum team in place and fill it with people who aren't capable of doing the job?

Maybe this manager with the better technical ideas needs to be on the team?

You want someone else to make the technical choice, but you think this team is going to be able to develop and schedule with this preferential technology when the entire team opposes it. Good luck with that.

I can't support an argument against something because there are situation where it won't work that aren't common. I would argue the teams described in this question would produce poor code regardless of the amount of supervision. If one manager could over-come the incompetence of an entire team, creating software wouldn't be so difficult, but that's not the case.


问:
Is it considered bad practice to have PHP in your JavaScript
So many times on this site I see people trying to do things like this :

```<code><script type="text/javascript">
  $(document).ready(function(){

     $('<?php echo $divID ?>').click(funtion(){
       alert('do something');
     });

  });
</script>
</code>```

I don't think that this is some sort of pattern that people naturally fall into. There must be some sort of tutorial or learning material out there that is showing this, otherwise we wouldn't see it so much. What I'm asking is, am I making too big a deal of this or is this a really bad practice?

EDIT :
Was speaking to a friend of mine about this who often puts ruby in his JavaScript and he brought up this point.

Is it ok to dynamically place application wide constants in your JavaScript so you don't have to edit two files. for example...

```<code>MYAPP.constants = <php echo json_encode($constants) ?>;
</code>```

also is it OK to directly encode data you plan to use in a library

```<code>ChartLibrary.datapoints = <php echo json_encode($chartData) ?>;
</code>```

or should we make an AJAX call every time?

答:
Containing the PHP into a config data object goes 90% of the way but best practice is to seperate it entirely. You can use a RESTful api to only request the data that you need, it is a bit more javascript but with a few advantages.

Script is static and can be cached permanently

PHP no longer an XSS Vector

Complete seperation of concerns

Downsides:

Requires an extra HTTP request

more complex javascript

Script

```<code>//pure javascript
$.on('domready',function({
    //load the data
    $.get({
       url:'/charts/3D1A2E',
       success: function(data){
           //now use the chart data here
           ChartModule.init(data);
       }
    });
})
</code>```

OwnerDisplayName: Greg Guida

Body:
Containing the PHP into a config data object goes 90% of the way but best practice is to seperate it entirely. You can use a RESTful api to only request the data that you need, it is a bit more javascript but with a few advantages.

Script is static and can be cached permanently

PHP no longer an XSS Vector

Complete seperation of concerns

Downsides:

Requires an extra HTTP request

more complex javascript

Script

//pure javascript
$.on('domready',function({
    //load the data
    $.get({
       url:'/charts/3D1A2E',
       success: function(data){
           //now use the chart data here
           ChartModule.init(data);
       }
    });
})


问:
What are the advantages of the delegate pattern over the observer pattern?
In the delegate pattern, only one object can directly listen to another object's events. In the observer pattern, any number of objects can listen to a particular object's events. When designing a class that needs to notify other object(s) of events, why would you ever use the delegate pattern over the observer pattern? I see the observer pattern as more flexible. You may only have one observer now, but a future design may require multiple observers.

答:
This is an old post but I'm going to chime in anyway because the other answers don't deal with what's happening when using either pattern, they seem to be more about theory than practice.

How Delegation and Observer Work

With Delegation the delegator picks exactly who is going to respond to a particular event the moment the source of the potential event is created. You could think of this listener as a single observer. In the case of the Observer pattern the observer picks who it's observing whenever it feels like it; so the dependancies are reversed when it comes to observer vs delegation.
 With the observer pattern think of a newspaper and subscribers as observers. The observers are in control of when the relationship gets created. With delegation think of an employee and an employer. The employer is in control of when the relationship gets created and exactly who is in charge of specific events. Employees can't pick what tasks they are working on...generally.

Some argue delegation can have one observer but I think the real difference between the two is how event handling is assigned. You will never see a delegate register for an event. It will never know its even handling the event till it happens and the delegator calls a public method on it.

Delegation Advantage

This pattern is very rigid and with most regid designs its simpler and generally more robust. It forces you to declare your event handler up front at the time of initializing the source of the potential event. If you need someone to direct traffic you assign a traffic director before you open up the street. In the case of the observer you would let the traffic cop choose when to direct traffic any time he or she felt like it.

Delegation Disadvantage

The disadvantage of this design is that it's not flexible. If you were implementing some code for subscribing for a newspaper the newspaper/delegator would have to identify exactly who can read the news stories the second they are created. With the observer pattern they can be registered later at any time and the newspaper will only have to know that a new person has signed up.

When To Choose Delegation?

When you need one specific observer(s) for sure and there is no reason for you to change who is observing then the rigid design of the delegation pattern will be beneficial.

For example, you need a class/object to handle creating a pop-up for a specific error. There aren't many reasons why at run-time you would need to switch who is handling a specific error so delegating the "Out-of Memory" error to a single entity would make sense. Creating an array of potential handlers and then having those handlers register for the "Out-of Memory" error wouldn't make much sense; that would be an example of using the observer pattern in this situation. At run-time you might want to change what methods get called or what "delegate" gets called for variable events but swapping out an event handler for a specific event at run-time isn't normal.

Its not impossible to swap delegates like you would do in the observer pattern, its just complicated. In the real world perhaps you want to swap traffic cops so a new delegator is handling traffic. One could argue that a better design would make original delegate a police station and not a single police officer but I digress...


答:
The scenarios you are describing can occur in any methodologies, they necessary don't have any thing to do with your Scrum/Agile adaptation.
If you are hiring developers who have already worked within Agile Framework most of them know the impact their coding might have on the maintenance aspect of the project.</p>


问:
How large non-OO code bases are managed?
I always see abstraction is a very useful feature the OO provides for managing the code-base. But how are large non-OO code bases are managed? Or do those just become a "Big Ball of Mud" eventually?

Update:

It seemed everyone is thinking 'abstraction' is just modularization or data-hiding. But IMHO, it also means the use of 'Abstract Classes' or 'Interfaces' which is a must for dependency-injection and thus testing. How non-OO code bases manage this? And also, other than abstraction, the encapsulation also helps a lot to manage large code bases as it define and restrict the relation between data and functions.

With C, it is very much possible to write pseudo-OO code. I don't know much about other non-OO languages. So, is it THE way to manage large C code bases?

答: The modularity principle is not confined to object-oriented languages.</p>


答:
To be honest I wouldn't change anything in your setup. It is exactly what we are doing now. I was playing around with setting up an separate git repository to handle the thirdparty lib that we use but I don't think it weighs up to the cost in portability. Now any developer can just checkout and get started without having to do any manual setup steps. And I any build server/slave can build the project.
Unless you have multi repos sharing the thridparty tools I would just stick with your current setup.

What I did play around with was setting up the thirdparty tools in a separate repo. Then I had one simple batch script read a text file with an sha1 ref and checkout the correct version. This would allow me to have different thirdparty versions for different projects. I got this idea from the Facebook Buck build tool. But in the end many developers don't like to use command line tools (MS VC shop here) so I gave up on the idea.

One major reason why not to download your thirdparty libs when you require them (using NuGet) is that if you need to support your product for a long time. In my industry, we need to sometime provide updates for old versions that rely on old thirdparty libs. We do not want to spend lots of time sorting out which libs we can upgrade or not and just use the libs as used in that version. Now imagine you use NuGet, oops... the latest version of the lib you require is 3.98 but you need 2.04..... how to explain to your boss that you need to spend 2 months to upgrade the old version to be able to use the latest libs when he was expecting a small change!

Title: Moving a multi-GB SVN repo to Git

Body:
Currently my company has a Visual Studio solition in an SVN repo that's organized as follows:

```<code>SolutionFolder (~3.5 GB)
|-> SolutionName.sln
|-> .. Some source code folders... (~250 MB)
|-> ThirdParty (~3 GB)
|-> Tools
    | -> Tool1
    | -> Tool2
</code>```

Tool1 and Tool2 are build independently (have their own solutions), but produce executables that are used in the main build.  ThirdParty folder contains all dependencies for the project, including some pre-compiled 100+ MB .lib files and large libraries like boost.

It's convenient to have it all in one SVN repo so that (1) developer has to do only one check-out, and (2) we don't need to keep track which versions of dependencies we need for each version of the build.  On the flip side, it takes a while to check out this repo.

What would be the best way to move this project structure to git?  Presumably it's best to exclude ThirdParty and possibly Tools from the main repo, but we'd like to keep ThirdParty easily downloadable in one step, and we like it versioned (and version mismatches between main repo and ThirdParty/Tools would be bad).

At this point I'm not interested in preserving history, just in figuring out how to organize such project.


问:
GitHub etiquette for duplicating a repo to change functionality
I've found a GitHub project I'd like to add some features to. After contacting the maintainer, the changes aren't in line with the direction he's going but he's interested to see what I do with it. What is the GitHub etiquette for using one repo as a base for another project that almost certainly won't ever be merged back into the original?

Instead of forking, my instinct is to create a brand new repo and manually copy the current state of the original code into it. Then, in the documentation, give credit and a link to the original author/repo for the starting point.

Is that acceptable, or is there some other standard approach?

答: I would just fork the project and make the the changes I find useful. Then I would make a pull request to original project. The maintainer can then decide to merge your request or not. At this point the link between your fork and the original project is clear. Any users of the original project will be able to find your ideas/changes and might even prefer to use your fork and this might then convince the original maintainer to accept your change in the future.</p>


问:
Private comments in git
I need to add a feature to some code in a big project and due to the complexity I find it very helpful to add detailed comments to many lines to keep track of what's happening. This is only for my own understanding however and I will delete the comments before pushing the code.

The problem however is that if I do private commits during my development, when I push to the main server, I guess git will show the lines that I commented and then uncommented (but didn't otherwise modify) as being modified by me, making "blame" more opaque.

I suppose the only way to do this cleanly is to have 2 private branches, one for development and one for commenting, or can anyone recommend a better way?

答:
So you need to add lots of comments to make the code readable and understandable - which is often a sign of, lets say, mediocre code quality. What makes you believe other team members would not benefit from those comments as well? Or that you won't need them again later, when you have to look at the same code again? Learn to write those comments in a way you don't have to remove them afterwards.

Or even better, instead of writing many comments, learn to refactor the code in a way it becomes more self-documenting, so lots of comments can be omitted.

If you really think you cannot change your habit of working that way, I suggest you leave your comments adding-and-deleting in the history. In a good team, there should be no reason to hide the way you work from the rest of the team.

Title: Private comments in git


答:
To directly answer your question:

If you take care to always use separate commits for adding comments, you can later remove these commits (using git rebase -i). As long as the comments and the other code changes do not touch the same lines (or lines very close to each other), the rebase should not produce any conflicts.

However, I agree with Doc Brown that you should try to write comments that can stay and help others. Of course, doing a final pass with rebase is probably still a good idea, to improve/fix comments (as your early comments might have been incorrect).

Also, instead of using comments, you might want to change variable and function names - that is often a better way to improve readability. But that's another question...

Title: Private comments in git

Body:
I need to add a feature to some code in a big project and due to the complexity I find it very helpful to add detailed comments to many lines to keep track of what's happening. This is only for my own understanding however and I will delete the comments before pushing the code.

The problem however is that if I do private commits during my development, when I push to the main server, I guess git will show the lines that I commented and then uncommented (but didn't otherwise modify) as being modified by me, making "blame" more opaque.

I suppose the only way to do this cleanly is to have 2 private branches, one for development and one for commenting, or can anyone recommend a better way?


答:
I agree that git rebase -i is correct way to remove local changes before pushing.

I also agree that if you feel the need to add comments to make the code understandable, they are likely to help your colleagues as well and therefore you should push them.

In either case the comments should be added in separate commit where you don't change anything else then comments. If you add the comments a bit at a time, you may consider combining the commenting commits using fixup command in git rebase -i to push in fewer pieces.

If you put the comments on separate lines, blame will only attribute the comment lines to you but not the code lines as they didn't change. Generally the code should not be too wide so it fits on the screen with IDE toolboxes on both sides, so there is rarely enough space at the end of line to do much explaining anyway.

Even if you do touch the lines and the blame will start attributing them to you, there is usually many changes to a line and when looking at a blame annotation, it's rare to be looking for the last change. There is no excuse for not looking at what the last change to the line was and not redoing the blame from the previous revision.

This is one of the reason why preferred option to be used when looking for some code is the "pickaxe", git log -Stext (and git log -Gpattern). If you give those only the code on the line, they won't find the commit that added a comment, only the commit that actually introduced the code.

And remember, making the code easier to understand, at least by renaming things to be more descriptive, is better then comments, because comments may become stale as the code is refactored, but the code itself can't.

Title: Private comments in git


答:
I have one more recommendation, though it's only partially relevant.

Put explanation of the code in the commit log!

When you do a change, especially to a code you don't understand very well or code that is non-trivial or non-obvious, it is useful to dump all your thoughts you had when making the change in the commit message.

Include what you found about how the code worked, detailed analysis of why it was wrong and explanation of how the change is supposed to fix it.

Unlike comments in the code that often get stale, comments in the commit log are attached to particular state of the code and can be selectively brought up by blame or "pickaxe" (log -S/log -G).

So next time you need to change some code, you'll run blame and log on it and read the comments and you should find all the explanations of how the code evolved with clear indication of which obsoletes which. And all that without cluttering the code.

Of course the comments should still stick to mainly explaining why and what in high level terms, while the low level terms of what and the how should be obvious from the code and if it's not, cleaning up the code is much better then commenting it.

Title: Private comments in git


问:
How to include license for MIT-licensed CSS?
I have a project licensed under the GPL. However, it includes a bit of code from animate.css, which uses the MIT license. How would I include the appropriate licensing information for that CSS? I've included that bit of css (maybe 25 or so lines) in my main stylesheet, so I'd rather not have a huge stamp like what's on this page, if I can avoid it.</p>

答: You main stylesheet is GPL, GPL requires whole derived work to be covered by GPL and MIT allows it. So you just mention the source, but I don't think you need to include the license since it does not apply anyway. Besides 25 lines is unlikely to be considered substantial portion anyway.</p>


问:
Nested Classes or Namespace
Why do need namespaces when we have nested classes. What can be done through namespaces, can also achieved through nested classes.

so I don't understand the reasoning of having namespaces ?

答:
The syntactic thing that makes the big difference is that struc-s definition aren't addictive: they begin with { and end with } and at that point cannot be "reopened" to add other members anymore.

Namespace, conversely, can be "reopened" and extended

```<code>// file F1.h
namespace A
{ /* some defs */ }

//file F2.h
namespace A
{ /* some other more defs */ }
</code>```

and can so be distributed on many different header each providing a closed set of classes.

If you include both F1.h anf F2.h you get all their definitions into A. This is hard (or even impossible, without convoluted preprocessing tricks) with struct & class.

On the inverse side, struct can be templetized, namespace cannot.

If classes could have been "reopened and extended" and namespaces tepletized, then the two concept will degenerate into one.

But "reopen-able classes" (think to the c# partial) due to the "inclusion text mechanism" and "multiple translation units" of C++ (that's not a symbolic import) will lead to different translation units seeing differently defined classes. If those different translation units go to form a single artifact (a same executable) it would be not possible to define a consistent size and consistent order of members. (not that this, for namespace global variables -acting like class members in the class-namespace analogy- leads to the well known "global initialization fiasco" problem, giving an unpredictable initialization order)

Hence the need of namespace to collect names without a composition/encapsulation mechanism.

Title: Nested Classes or Namespace

Body:
The syntactic thing that makes the big difference is that struc-s definition aren't addictive: they begin with { and end with } and at that point cannot be "reopened" to add other members anymore.

Namespace, conversely, can be "reopened" and extended

// file F1.h
namespace A
{ /* some defs */ }

//file F2.h
namespace A
{ /* some other more defs */ }

and can so be distributed on many different header each providing a closed set of classes.

If you include both F1.h anf F2.h you get all their definitions into A. This is hard (or even impossible, without convoluted preprocessing tricks) with struct & class.

On the inverse side, struct can be templetized, namespace cannot.

If classes could have been "reopened and extended" and namespaces tepletized, then the two concept will degenerate into one.

But "reopen-able classes" (think to the c# partial) due to the "inclusion text mechanism" and "multiple translation units" of C++ (that's not a symbolic import) will lead to different translation units seeing differently defined classes. If those different translation units go to form a single artifact (a same executable) it would be not possible to define a consistent size and consistent order of members. (not that this, for namespace global variables -acting like class members in the class-namespace analogy- leads to the well known "global initialization fiasco" problem, giving an unpredictable initialization order)

Hence the need of namespace to collect names without a composition/encapsulation mechanism.


答:
I would consider this bad practice. When putting dynamic content inside script blocks you always must be aware of the fact that escaping inside a javascript context is not as simple as you would hope. If values were user-provided, it is not sufficient to html-escape them.

The OWASP XSS cheat sheet has more details, but basically you should adopt this pattern:

```<code><script id="init_data" type="application/json">
    <?php echo htmlspecialchars(json_encode($yourdata)); ?>
</script>
</code>```

Then in a separate .js file linked from your main html, load this code:

```<code>var dataElement = document.getElementById('init_data');
var jsonText = dataElement.textContent || dataElement.innerText  // unescapes the content of the span
var initData = JSON.parse(jsonText);
</code>```

The reason for using a separate .js file is two-fold:

It is cacheable so the performance is better

The HTML parser is not triggered, so there is no risk of a XSS bug slipping through by someone putting a quick <?php tag in there somewhere

Title: Is it considered bad practice to have PHP in your JavaScript

Body:
So many times on this site I see people trying to do things like this :

```<code><script type="text/javascript">
  $(document).ready(function(){

     $('<?php echo $divID ?>').click(funtion(){
       alert('do something');
     });

  });
</script>
</code>```

I don't think that this is some sort of pattern that people naturally fall into. There must be some sort of tutorial or learning material out there that is showing this, otherwise we wouldn't see it so much. What I'm asking is, am I making too big a deal of this or is this a really bad practice?

EDIT :
Was speaking to a friend of mine about this who often puts ruby in his JavaScript and he brought up this point.

Is it ok to dynamically place application wide constants in your JavaScript so you don't have to edit two files. for example...

```<code>MYAPP.constants = <php echo json_encode($constants) ?>;
</code>```

also is it OK to directly encode data you plan to use in a library

```<code>ChartLibrary.datapoints = <php echo json_encode($chartData) ?>;
</code>```

or should we make an AJAX call every time?

Body:
I would consider this bad practice. When putting dynamic content inside script blocks you always must be aware of the fact that escaping inside a javascript context is not as simple as you would hope. If values were user-provided, it is not sufficient to html-escape them.

The OWASP XSS cheat sheet has more details, but basically you should adopt this pattern:

<script id="init_data" type="application/json">
    <?php echo htmlspecialchars(json_encode($yourdata)); ?>
</script>

Then in a separate .js file linked from your main html, load this code:

var dataElement = document.getElementById('init_data');
var jsonText = dataElement.textContent || dataElement.innerText  // unescapes the content of the span
var initData = JSON.parse(jsonText);

The reason for using a separate .js file is two-fold:

It is cacheable so the performance is better

The HTML parser is not triggered, so there is no risk of a XSS bug slipping through by someone putting a quick <?php tag in there somewhere

ContentLicense: CC BY-SA 4.0


答:
A class is a definition of a type.

A namespace is a 'container' for a related set of these defined types.

Really two very different things serving different purposes. Just because you can mimic the use of one by using another doesn't mean they are necessarily interchangeable.

Equally, I could use a String variable to store a number. It would, in some cases, behave the same. But it's not conducive to good practice or even using these features as what they were originally itended for.

Title: Nested Classes or Namespace

Body:
Why do need namespaces when we have nested classes. What can be done through namespaces, can also achieved through nested classes.

so I don't understand the reasoning of having namespaces ?


答:
IANAL, but instead of putting the whole license terms in your your CSS it's often common to put just its name and a link to the full termsso something like this would do:

```<code>/* Licensed under the MIT/X11 License (http://opensource.org/licenses/MIT) */
</code>```

Plus, as your project is GPL and you're forced to redistribute the whole source anyways, you'll have your own code-repository or code archive somewhere, in which you could have a LICENSE or CONTRIBUTING text file containing the licensing terms for your app (GPL) and dependencies (here the MIT/X11 for that bit of CSS). That's a pretty common way to go about things.

Another good example to follow (but here with GPL and MIT instead of ASL or what have you) is outlined in the Apache Foundation Developer's Guide section on Assembling Licenses.

Title: How to include license for MIT-licensed CSS?

Body: I have a project licensed under the GPL. However, it includes a bit of code from animate.css, which uses the MIT license. How would I include the appropriate licensing information for that CSS? I've included that bit of css (maybe 25 or so lines) in my main stylesheet, so I'd rather not have a huge stamp like what's on this page, if I can avoid it.</p>

Body:
IANAL, but instead of putting the whole license terms in your your CSS it's often common to put just its name and a link to the full termsso something like this would do:

/* Licensed under the MIT/X11 License (http://opensource.org/licenses/MIT) */

Plus, as your project is GPL and you're forced to redistribute the whole source anyways, you'll have your own code-repository or code archive somewhere, in which you could have a LICENSE or CONTRIBUTING text file containing the licensing terms for your app (GPL) and dependencies (here the MIT/X11 for that bit of CSS). That's a pretty common way to go about things.

Another good example to follow (but here with GPL and MIT instead of ASL or what have you) is outlined in the Apache Foundation Developer's Guide section on Assembling Licenses.


问:
Force users to update to the latest version of my app on the Google Play Store
Is there a way to have a "critical update" for my app on the Google Play Store that would require the user to update the app to keep using it?

For instance, let say I push an update that brings a few bugfixes. Nothing mandatory, the user updates it if he wants to: that's a non-critical update.

Now, say I correct a very serious security issue on my app and want all the users to update to this version to keep using the app: this is a critical update.

Basically, if there is a critical update and the user has not updated yet, he cannot use the app until he does so.

Is this possible using the Play Store?

Thanks for your feedback!

答:
It should not be your responsibility to decide what users need or want to run on their devices.

The best way to handle the situation you describe is to notify users that a critical security bug fix has been released and that everybody should update the app.


答: Fork. Even if the original repo's author never accept your changes, it is still very likely you will want to pull their updates, and having the original repo as upstream will make this easier.

Title: GitHub etiquette for duplicating a repo to change functionality

Body:
I've found a GitHub project I'd like to add some features to. After contacting the maintainer, the changes aren't in line with the direction he's going but he's interested to see what I do with it. What is the GitHub etiquette for using one repo as a base for another project that almost certainly won't ever be merged back into the original?

Instead of forking, my instinct is to create a brand new repo and manually copy the current state of the original code into it. Then, in the documentation, give credit and a link to the original author/repo for the starting point.

Is that acceptable, or is there some other standard approach?


问:
How to use lists in equivalence partitioning?
I have read that equivalence partitioning can be used typically for intervals or lists, e.g. I assume it can be used for every set of inputs.
Anyway if the requirement says that allowed colors are (RED,BLUE,BLACK, GREEN), I cannot treat them like a list, right? I mean, testing one of them would not be enough because developers most likely used some switch-case and thus it is not real "set" where one could represent also the others.
So how it is meant with lists?

Also what is not that clear to me, I do not think it is always possible to do the initial partioning and then design the test cases.

   What about checking two lines intersection:   Y=MX+C. (two inputs)

1) The lines are paraller. M1=M1 but C1 must be different from C2.

2) Lines are intersecting. M1 must be different from M2.

3) Coincident. The are the same.

How can I use partitioning here? THis is actually taken from a book and it says that these sets are eq.classes.

答:
How can I use partitioning here? THis is actually taken from a book and it says that these sets are eq.classes.

I guess, the equivalence relation you are considering is defined in
terms of the program flow as follows:

Given a program, we say that input data A and B are equivalent
  if the processing of A and B yields the same workflow in your
  program.

The same workflow means that the same procedures will be called and
the same decisions will be made in the same order.  (Most probably, we
could express this by saying that the sequences of adresses that the
instruction pointer visit when processing A agrees with the
sequences resulting from the processing of B.)

In order to use paritioning, you consider all decisions made by the
code you analyse and use these to find equivalence classes.  Once you
have these classes, pick any data in each class—this yields a system
of representatives—and use this system of representatives to test your
code.


答:
You can use submodules for the tools. That way you can keep them in a subdirectory like you do now, and use a separate repo for versioning them. That also means you could clone(checkout) the tools and develop them separately, and that other projects could rely on those repos - and on specific, udateable versions of them too.

You could also use submodules for the third party libraries, but if at all possible I would recommend using a dependency manager for those.

Title: Moving a multi-GB SVN repo to Git


问:
Android: Considering an ORM tool
I am developing an Android app in which I have to add chat functionality. Also, I have to save the chat history. I will accomplish this task using SQlite. But, I am not sure whether should I consider using an ORM like GreenDAO or ORMLite or I should use traditional way of persisting data in SQLite.

Actually, I am not clear when should go for using an ORM and how do I get benefit from it.

答:
There are two fundamental reasons for using ORM tools. Knowing which one applies to you makes the decision easier.

Many people use automatic mapping because they don't want to deal with database access at all. Maybe they don't understand it, or they don't want to think about it, or they are certain that they will never require any functionality that goes beyond the lowest common denominator of relational persistence that ORM can give you. In that case, this is a useful trade-off: less development work on peripheral issues equals more time to spend on developing core issues. The price, of course, is loss of control and expressiveness for advanced persistence strategies - usually, you'd hope, precisely the advanced stuff you weren't going to use anyway.

Others want a strong abstraction from the actual data storage because they anticipate that they might change their database, or have to support different engines from the get-go. In that case, the tools help you by ensuring that you don't intermix low-level and business-level logic at all. In other words, all the things that would cause additional work if you later changed databases are automatically prohibited. This is a useful method of enforcing development discipline for things you shouldn't do anyway (but might do by accident). However, the benefits are real only if you actually rip out and replace your persistence provider - otherwise, they contribute to the normal good practice of layering/not repeating yourself etc., but not more than that. If you're on a mobile platform and have no choice in which database will power your app, then this motivation doesn't really make sense.

Title: Android: Considering an ORM tool


答:
Use the proper tool for the job. In Windows, that means

Use NuGet for third-party dependencies

That way, you keep the third-party dependencies in a versioned way, but you will not bloat your repository with unneeded stuff. Checkouts are much faster, and the project is organized as it should be. You can enable an option in Visual Studio so it always downloads all dependencies automatically.

Of course you can use a solution that just uses git (another repo, submodules etc), but that's just hacks. Doing it the right way will pay off quickly, and leave you with a future-proof system.

Edit after comments:
The best way to use NuGet is to set up a local NuGet source, either on a shared drive, or a full nuget server. Setup shouldn't take more than a few minutes either way. That way, you can guarantee that all the packages you need are always available, no matter where they originated.

Title: Moving a multi-GB SVN repo to Git


问:
Why does DrRacket IDE considers some identifiers as "symbols" and some as "keywords"? What is the difference?
Why does DrRacket (kind of Scheme) IDE highlights some of the identifiers as "keywords" (for example define, lambda, send*), and the others as "symbols" (user defined identifiers, +, -, abs, send, send+, etc.)?

I am particularly confused by the difference between send* and send+.  For reference, here are the beginnings of their definitions:

```<code>(define-syntax (send* stx) ...

(define-syntax (send+ stx) ...
</code>```

(It is possible that I do not use the terms "identifier", "symbol", and "keyword" completely correctly, but this is how some of them seem to be used in DrRacket preferences.)

Unless this is a bug, it must be explained by the language "semantics", so I decided to ask here.

答:
DrRacket maintains a list of keywords that it understands for auto-indentation, which you can find in the Preferences (under Editing->Indenting). If an identifier is listed as a keyword for indentation, then DrRacket will also highlight it differently if the chosen color scheme differentiates keywords from plain identifiers.

Identifiers like + are not highlighted because they are just names of functions, not "special forms" like if and cond. On the other hand, send+ isn't highlighted just because the default DrRacket keywords don't contain every syntactic form provided by Racket.


问:
Is thinking out loud during an interview really the best strategy?
In another question I asked recently about best practices for whiteboarding, there was general consensus that thinking out loud while coming up with the answer was the best strategy.

Indeed, long moments of silence are awkward.

However after recent interviews I have noticed that if my thinking out loud leads to wrong solutions or down the wrong path, that with further consideration I would have seen, interviewers tend to quickly jump in and point out problems with my approach, especially if I stop to pause for a minute. This was not an isolated case, and happened during more than one interview with more than one interviewer.

The other thing is that after the interview, on a problem I absolutely bombed, when I sat down and sketched out the problem on a piece of paper in silence I was able to sketch out the solution pretty quickly. Thinking out loud ends up with me spending brain cycles on reflecting on how what I say must be registering with the interviewer and in addition there's a fear of recognizing that I've gone down the wrong path and starting over after having written something on the board wastes a lot of time. Once you've started down one path and realize you've written a lot of junk, you can't undo it, whereas if you've thought quietly about it the interviewer wouldn't have seen the mess and it would have been quicker since whiteboarding a bad idea takes up more time than simply considering a bad idea.

I don't want moments of silence but at the same time speaking takes more time, leads to self-consciousness and can lead to interviewer intervention on something I might have figured out myself with just a little more time.

答:
I've read that people who talk to themselves are significantly better problem solvers.

So perhaps you can just mumble to yourself and make the best of both.  :-)  Seriously.

You'll be a better prob. solver and they won't get to hear the full details of your search tree, including the dead end nodes.


答:
For this to work, some kind of logic the app uses needs to be under your control. And then without that part of logic the app won't work and you can show a message: "your app is out of date, please download the new version to continue use."

Consider a messenger app where traffic goes through your servers. Just refuse to deliver messages of clients using an outdated version.

Title: Force users to update to the latest version of my app on the Google Play Store

Body:
Is there a way to have a "critical update" for my app on the Google Play Store that would require the user to update the app to keep using it?

For instance, let say I push an update that brings a few bugfixes. Nothing mandatory, the user updates it if he wants to: that's a non-critical update.

Now, say I correct a very serious security issue on my app and want all the users to update to this version to keep using the app: this is a critical update.

Basically, if there is a critical update and the user has not updated yet, he cannot use the app until he does so.

Is this possible using the Play Store?

Thanks for your feedback!


问:
Do Scrum sprints mean to work at the fastest pace possible?
I recently interviewed with some companies that do Agile, Scrum to be more precise and there are some things that don't quite seem like Agile to me. I'll take one case that particularly interests me right now, that of Scrum sprints.

One particular project manager I talked to (yes, I said project manager) proudly stated that people in her team understand ("were told" is what I picked up from the context) that you don't go home when the working hours are over, you go home when the job is done, no matter how much it takes. What I've read in between the lines is that we pack as much features as possible into a sprint and work overtime to make it happen.

Now, I haven't done Agile by now (worked with financial and governmental institutions which most still do prefer waterfall) but my understanding is that:

sprint in Scrum is the name for the generic iteration in Agile;

the team should work at a sustainable pace and try to avoid long term overtime as that has effects only on the short time and the effects are dwarfed by the problems they incur in the long time.

Are my statements right? And, should I take the manager's presentation as a red flag?

答: Yes, you're right, and if I were told what you were told, I'd run away from there as fast as possible. They're just using agile as an excuse. Sounds like the classic death march.</p>


答:
There is one key thing that may make this acceptable: the team accepts the scope of the sprint.

In Scrum, teams don't just get assigned work. The product owner negotiates with the team to prioritize product work and technical (debt) work. The project manager, product owner, and team then negotiate on what gets pulled into a sprint and what the scope of that work is.

In this world, the team is essentially saying "we can get X work done, tested and shipped this iteration". So I would expect a team to occasionally work overtime to meet these commitments.

That said, so many places bastardize agile - and so few team leads can negotiate effectively with people who are usually their bosses... I would take this as a huge red flag.

Title: Do Scrum sprints mean to work at the fastest pace possible?

Body:
I recently interviewed with some companies that do Agile, Scrum to be more precise and there are some things that don't quite seem like Agile to me. I'll take one case that particularly interests me right now, that of Scrum sprints.

One particular project manager I talked to (yes, I said project manager) proudly stated that people in her team understand ("were told" is what I picked up from the context) that you don't go home when the working hours are over, you go home when the job is done, no matter how much it takes. What I've read in between the lines is that we pack as much features as possible into a sprint and work overtime to make it happen.

Now, I haven't done Agile by now (worked with financial and governmental institutions which most still do prefer waterfall) but my understanding is that:

sprint in Scrum is the name for the generic iteration in Agile;

the team should work at a sustainable pace and try to avoid long term overtime as that has effects only on the short time and the effects are dwarfed by the problems they incur in the long time.

Are my statements right? And, should I take the manager's presentation as a red flag?


问:
Junior developers in a remote working environment
Our company is looking to introduce remote working as an option for its developers.

This book (Remote: Office not required) has been offering some valuable guidance.

However one issue that is not addressed is the employment and management of junior level developers.

In a remote working environment, how do you ensure that junior developers receive the same standard of guidance and experience that they would gain from being around more senior developers in an office environment?

答:
The same way you do in a non-remote working environment: code-reviews, code-reviews, code-reviews. Use headsets and a good collaborative software which allows two people to work together virtually on the same screen.

Of course, for things like making a sketch on a piece of paper or a physical whiteboard you need an electronical pendant, but that should not be much of a problem.

EDIT: of course, there is also a lot of truth in what @JayScott wrote: having junior devs completely out of your local office introduces some risk that you loose some effectiveness in guidance and quality, that's unavoidable. But IMHO this depends a lot on the actual people involved.


答:
In my opinion, not possible. Doc Brown's outlined the main way you can ensure as much progress and quality as possible, but I don't think this will equate to the quality of guidance and progress monitoring a junior would receive whilst working in an office.

To address your question - mimic an office environment as much as possible using conferencing and collaboration technologies, but I do think even with this you're taking a risk.

NOTE: I say 'not possible' because you've stated they're junior, and I'm very aware of how much extra guidance is needed in any scenario with a junior developer. For what it's worth, I think senior developers benefit from having the space to work remotely over an office environment.

Title: Junior developers in a remote working environment

Body:
Our company is looking to introduce remote working as an option for its developers.

This book (Remote: Office not required) has been offering some valuable guidance.

However one issue that is not addressed is the employment and management of junior level developers.

In a remote working environment, how do you ensure that junior developers receive the same standard of guidance and experience that they would gain from being around more senior developers in an office environment?


问:
Structuring asynchronous javascript code
I am working on an application that heavily depends on asynchronous data operations. I am dealing with those through promises.

However, while my code works, I have the feel that it is getting chaotic and hard to maintain in the future.

Assume this:

```<code>validate().then(

// success
function(promise){
    $http.post('stuff.php',data).then(

      function(p){

      },
      function(){

      }
    )
},

// failure
function(reason){
    // Assume another promise-depending operation
},

// notification
function(update){

}
);
</code>```

As you can see, promise calls are heavily nested. Furthermore, I have to deal with resolve/reject methods in each and every step.

What am I missing; how can I improve my technique?

答:
You seem to be using promises the same way someone would use callbacks. While you can do that it doesn't really make sense, callbacks can do that too.

Main feature of promises is that resolvers/handlers can return value and it allows a chaining, consider following example:

```<code>  function capitalise (word) {
    letters = word.split('');
    letters[0] = letters[0].toUpperCase();
    return letters.join('');
  }

  function exclamate (word) {
    return word + '!'
  }

  function log (word) {
    console.log("Word is:", word);
    return word
  }

  // Let's say that getWord is asynchronous operation (say ajax)
  // that returns a promise.
  word = getWord("i want coffee");
  word.then(capitalise).then(exclamate).then(log);
</code>```

Body:
You seem to be using promises the same way someone would use callbacks. While you can do that it doesn't really make sense, callbacks can do that too.

Main feature of promises is that resolvers/handlers can return value and it allows a chaining, consider following example:

  function capitalise (word) {
    letters = word.split('');
    letters[0] = letters[0].toUpperCase();
    return letters.join('');
  }

  function exclamate (word) {
    return word + '!'
  }

  function log (word) {
    console.log("Word is:", word);
    return word
  }

  // Let's say that getWord is asynchronous operation (say ajax)
  // that returns a promise.
  word = getWord("i want coffee");
  word.then(capitalise).then(exclamate).then(log);


答:
The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

So... You must include it somehow.

Definitely leave the (c) copyright 2014 So-and-So, it's that person's hard work after all.

Then you can link the MIT licensing information by just adding a url to it. Just make sure that the license is available and that link doesn't go down. I'd recommend just putting the license in a .txt file on your server so you know it's available.


问:
How do I test this?
I've attempted test first in Ruby on Rails using Test Unit and RSpec.

I'm wondering how to do test first in situations that are more closely tied to the OS/filesystem.

Problem: Building a USB stick of MP4 files.

Inputs:

List of mp4 file name, destination directory pairs.

List of source directories

List of destination directories

Output:

USB stick with a directory structure of mp4 files.

Here is some code that does what I want. Written using puts debugging:

```<code>#!/bin/env ruby
# encoding: utf-8

require 'fileutils'

files = [
    [ 'Keynote_ Architecture the Lost Years by Robert Martin.mp4', 'dev' ],
    [ 'The Oak Beams of New College, Oxford.mp4', 'arch' ],
    [ '1. How Buildings Learn - Stewart Brand - 1 of 6 - “Flow”.mp4', 'arch/how_buildings_learn' ],
    [ 'Hexagonal Rails by Matt Wynne.mp4', 'dev' ]
]

dirs = [
    'arch',
    'arch/how_buildings_learn',
    'dev'
]

sources = [
    '/home/gnoll110/dwhelper',
    '/home/gnoll110/Downloads',
    '/home/gnoll110/GNUstep/Downloads',
    '/home/gnoll110'
]

dest = '/media/Lexar'

dirs.each do | dir |
    if !File.exist?( dest+'/'+dir )
        system( 'mkdir '+dest+'/'+dir )
    end
end

files.each do | file |
    actual_source = false
    sources.each do | source |
        res = File.exist? source+'/'+file[0]
        actual_source = source if res
    end

    if actual_source
        FileUtils.cp(actual_source+'/'+file[0], dest+'/'+file[1] )
    end
end.
</code>```

What the best approach?

Junk the existing code. After all, I'm trying to do test first.

Write a test(s) that invokes a Command Pattern object. Dependence inject the data arrays in the constructor.

Then inject the 'file exist' and 'fileutils copy' as stub/mocks, to get separation from the OS/filesystem.

Build, assert and refactor the run method within an inch of its life.

All suggestions and ideas welcome.

答:
You have asked two questions:

How to test drive code which touches the filesystem

Should you junk your existing untested code.

Re: How to test drive code which touches the file system:

The best way to do this is to put the filesystem calls behind an interface which will be mocked out for unit testing of the rest of the system. Only your applications 'main' function will instantiate the real versions of these methods.

The code that contains the real filesystem calls should be very thin so that you can either not bother testing it (since you can verify it by inspection or by quick smoke-test of the entire system) or test it with a few integration tests which use the real filesystem.

Re: Junking existing code:

This is a judgement call on your part.

You could consider your existing code as a prototype which helped you learn the sort of thing you need to do. If that is the case then you should delete it and write it again now that you have better knowledge.

Or you could consider it legacy code and get it under test. To do that write some full system tests to keep you from breaking it as you refactor it. See "Working Effectively with Legacy Code" by Michael Feathers for techniques to do this safely.

Title: How do I test this?


问:
Additional actions in setup.py for install
Background

So, I'm developing a project, and I'm writing setup.py script for it, using distutils. I'm using CPython3.3.

I use some libraries that have invalid distributions in PyPI, so they have to be installed by cloning repo and running setup.py manually (I've tried many things, both libraries help said I just need to use git instead of PyPI, so why I need to do that this way is not a question here).

So, I've used some subprocess magic, and created script that clones repos and runs "setup.py install" in them. It also runs apps setup.py, after ensuring that broken libs are already installed other way. It is easy to convert to several methods, and will be enhanced in few moments. At the moment my app may be installed by running this script (I called it build.py).

Question

How do I create a hook in my setup.py script (for my app) that will run methods installing things from github when (and ONLY when) "install" argument was passed to apps setup.py?

What I've tried

I tried googling phrases like "how do I hook setup.py" - more or less general, I tried several queries. Nothing has been found.

Also, I tried to analyze distutils source, to find some way, but that also got me nowhere.

Haven't tried it yet, but I know it is doable - at the beginning of setup.py script checking whether conditions like "it is ran as main script" and "'install' keyword is in sys.argv" are true, and if so - running my git-related methods, but this is ugly as hell.

答:
Do not handle installation of dependencies in your setup.py. Only handle packaging your own project, and leave dependencies to the specialized tools such as pip and buildout.

If in the future those packages see better releases on PyPI, all you need to do is change your installation instructions, not create a new release with a new setup.py, even though no functionality changed.

You can provide a requirements.txt file for pip installation, or a buildout.cfg for buildout, both of which can include information to let the tool pull dependencies directly from github instead of from PyPI.

See https://caremad.io/blog/setup-vs-requirement/ for a good blog post on the same subject.


问:
Constructor Injection, Single Responsibility and List initialisation
Given the class:

```<code>public class Foo : IFoo
{
  private IBarRepository repository

  public Foo(IBarRepository repository)
  {
     this.repository = repository
  }

  public IList<IBar> Bars { get; private set; }
}
</code>```

My long standing instinct is to initialise the list of IBar in the constructor: this.Bars = new List<IBar>(); but using Constructor Injection, the Single Responsibility of the constructor is for it to set the dependancies for the class.

What is the best way to handle this?

Should I have a collection initialiser that I call in any method before using the collection?

```<code>private void InitialiseCollection()
{
  if (this.Bars == null)
  {
     this.Bars = new List<IBar>();
  }
}

public void Add(IBar bar)
{
    this.InitialiseCollection();
    this.Bars.Add(bar)
}
</code>```

答: The Single Responsibility principle applies to the class as a whole, not just to the constructor. Also, resist the urge to initialize the Bars variable using that last method - if you are using injection, it should be responsible for giving you a complete and working instance of Foo or none at all if it can't resolve the object to pass to the constructor.</p>


问:
Finding patterns in logs
I am trying to put together a way to figure out if incidents occurred based on log content. Typically, on log (or DB table) would contain a list of transactions composed as follow:
{Timestamp} {TransactionID} {Message}

As an example problem I have run into, I used this to detect if "incidents" occured by running some very basic queries such as:

```<code>SELECT Timestamp, count(*)
FROM table
GROUP BY Timestamp
HAVING COUNT(*) > 5
ORDER BY Timestamp
</code>```

This works OK but has very strong caveats:

In times of high activity it will return records for nothing (and raising the bar will hide rows that should get returned)

Let say I have 4 events at timestamp t and 2 events at timestamp (t+1), my query will not return anything even if they should be considered. Unfortunately, aggregating timestamps by time ranges will lead me to the previous point about high activity time.

Would someone have some insights on how to tackle the broader problem of incident detection within logs?

答:
Would someone have some insights on how to tackle the broader problem of incident detection within logs?

There is two classical approaches to this problem.

In the first approach, you have a precise list of incidents you want to report. For each of these incident, you pick a kind of “mathematical definition” and a formal test for the incident.  Most probably, your dictionary of incidents may evolve with time.  Interestingly, you can put incident reports in the event flow you are analysing, which gives you the ability to define incidents patterns at a higher level.

In the second approach, you have a large database of “normal activity” and your statistic skills are in good shape.  You then define numerical observables (like the time between two transactions, or the daily rate of some transaction, or whatever seems to make sense for your problem) and then apply univariate outliers detection methods.

The first approach gives you the opportunity to detect known incidents, the second gives you the chance to “see that something odd happens” bu will require you to look at what is actually going on.

Most probably you may want to use a mixture of both approaches, but you definitely need to analyse the importance and the likelyhood of each incident type before devising an efficient strategy.

Title: Finding patterns in logs


答:
Well, the simple answer to your question is

```<code>public readonly IList<IBar> Bars = new List<IBar>();
</code>```

But I think you should question your premise.

but using Constructor Injection, the Single Responsibility of the constructor is for it to set the dependancies for the class.

Where have you read that? It's entirely incorrect.

It doesn't matter if you're using Constructor Injection or not. Your constructor's responsibility is to construct an object, fully initialized, with all the dependencies required to operate on that object. Those dependencies can be other services or state or values that distinguish this object from another object of its type.

Title: Constructor Injection, Single Responsibility and List initialisation

Body:
Given the class:

```<code>public class Foo : IFoo
{
  private IBarRepository repository

  public Foo(IBarRepository repository)
  {
     this.repository = repository
  }

  public IList<IBar> Bars { get; private set; }
}
</code>```

My long standing instinct is to initialise the list of IBar in the constructor: this.Bars = new List<IBar>(); but using Constructor Injection, the Single Responsibility of the constructor is for it to set the dependancies for the class.

What is the best way to handle this?

Should I have a collection initialiser that I call in any method before using the collection?

```<code>private void InitialiseCollection()
{
  if (this.Bars == null)
  {
     this.Bars = new List<IBar>();
  }
}

public void Add(IBar bar)
{
    this.InitialiseCollection();
    this.Bars.Add(bar)
}
</code>```

Body:
Well, the simple answer to your question is

public readonly IList<IBar> Bars = new List<IBar>();

But I think you should question your premise.

but using Constructor Injection, the Single Responsibility of the constructor is for it to set the dependancies for the class.

Where have you read that? It's entirely incorrect.

It doesn't matter if you're using Constructor Injection or not. Your constructor's responsibility is to construct an object, fully initialized, with all the dependencies required to operate on that object. Those dependencies can be other services or state or values that distinguish this object from another object of its type.


答:
The reason usually given for having remote junior developers is cost savings. People in the decision-making chain needs to understand the effort involved to make the cost savings possible and not assume that offshoring automatically equals big cost savings.

I (based in North America) got a successful team of junior developers in Bangaluru to be self-sustaining as a remote entity, but it takes work.  I went to India and trained a team of eight developers for three weeks.  During this time I got a sense for how each worked on their own as part of the larger team (helping their co-workers, taking leadership roles, etc.). Then I whittled down the team to the four who made the strongest team.  When I returned to North America I committed to pairing with remote team members via web conference during their business hours (middle of my night).  The other US-based senior developer and I did code reviews of all changes made for several months, always requiring robust unit tests for any committed code.

So it was a lot of work but we were able to retain the team for a few years and it probably saved a little bit of money.

As stated in other comments/answers, mentoring less experienced resources is important, and doing so remotely is more difficult than doing so in person.  But it is possible.