问:
Hibernate set up for beginner
I am learning Hibernate (OR Mapping). I am using Maven for project management. However, I am currently reading a Hibernate book by O'Reilly, and they use ANT for their example. So my question is are there any difference between setting up hibernate with ANT and Maven?

Thanks in advance!

答:
If you want to see a complete web application that provides:

Hibernate configuration through Spring

DAOs with Spring's HibernateTemplate

DTOs with JPA annotations (@Column, @OneToOne, @OneToMany, @ManyToOne etc)

examples of Hibernate user types for persisting Joda Time and Joda Money

then you might want to refer to the MultiBit Merchant project on GitHub.

It also features examples of RESTful APIs with HAL and uses Dropwizard which may come in useful to you later on when you come to integrate your Hibernate work into a web application. All the code is MIT license so just take it and use it.

Title: Hibernate set up for beginner


问:
Python Forgiveness vs. Permission and Duck Typing
In Python, I often hear that it is better to "beg forgiveness" (exception catching) instead of "ask permission" (type/condition checking).  In regards to enforcing duck typing in Python, is this

```<code>try:
    x = foo.bar
except AttributeError:
    pass
else:
    do(x)
</code>```

better or worse than

```<code>if hasattr(foo, "bar"):
    do(foo.bar)
else:
    pass
</code>```

in terms of performance, readability, "pythonic", or some other important factor?

答:
It really depends on how often you think the exception is going to be thrown.

Both approaches are, in my opinion, equally valid, at least in terms of readability and pythonic-ness. But if 90% of your objects do not have the attribute bar you'll notice a distinct performance difference between the two approaches:

```<code>>>> import timeit
>>> def askforgiveness(foo=object()):
...     try:
...         x = foo.bar
...     except AttributeError:
...         pass
...
>>> def askpermission(foo=object()):
...     if hasattr(foo, 'bar'):
...         x = foo.bar
...
>>> timeit.timeit('testfunc()', 'from __main__ import askforgiveness as testfunc')
2.9459929466247559
>>> timeit.timeit('testfunc()', 'from __main__ import askpermission as testfunc')
1.0396890640258789
</code>```

But if 90% of your objects do have the attribute, the tables have been turned:

```<code>>>> class Foo(object):
...     bar = None
...
>>> foo = Foo()
>>> timeit.timeit('testfunc(foo)', 'from __main__ import askforgiveness as testfunc, foo')
0.31336188316345215
>>> timeit.timeit('testfunc(foo)', 'from __main__ import askpermission as testfunc, foo')
0.4864199161529541
</code>```

So, from a performance point of view, you need to pick the approach that works best for your circumstances.

In the end, some strategic use of the timeit module may be the most Pythonic thing you can do.

ContentLicense: CC BY-SA 3.0

Body:
It really depends on how often you think the exception is going to be thrown.

Both approaches are, in my opinion, equally valid, at least in terms of readability and pythonic-ness. But if 90% of your objects do not have the attribute bar you'll notice a distinct performance difference between the two approaches:

>>> import timeit
>>> def askforgiveness(foo=object()):
...     try:
...         x = foo.bar
...     except AttributeError:
...         pass
...
>>> def askpermission(foo=object()):
...     if hasattr(foo, 'bar'):
...         x = foo.bar
...
>>> timeit.timeit('testfunc()', 'from __main__ import askforgiveness as testfunc')
2.9459929466247559
>>> timeit.timeit('testfunc()', 'from __main__ import askpermission as testfunc')
1.0396890640258789

But if 90% of your objects do have the attribute, the tables have been turned:

>>> class Foo(object):
...     bar = None
...
>>> foo = Foo()
>>> timeit.timeit('testfunc(foo)', 'from __main__ import askforgiveness as testfunc, foo')
0.31336188316345215
>>> timeit.timeit('testfunc(foo)', 'from __main__ import askpermission as testfunc, foo')
0.4864199161529541

So, from a performance point of view, you need to pick the approach that works best for your circumstances.

In the end, some strategic use of the timeit module may be the most Pythonic thing you can do.


问:
Inspection, code review - is it really testing?
ISTQB, Wikipedia or other sources classify verification acitivities (reviews etc.) as a static testing, yet other do not. If we can say that peer reviews and inspections are actually a kind of a testing, then a lot of standards do not make sense (consider e.g. ISO which say that validation is done by testing, while verification by checking of work products) - it should at least say dynamic testing for validation, shouldn't it?
I am completing master thesis dealing with QA and I must admit that I have never seen worse and more ambiguous and contradicting literature than in this field :/
Do you think (and if so, why) that static testing is a good and justifiable term or should we stick to testing and static checks/analysis?

Wikipedia: Static testing is a form of software testing where the software isn't actually used. This is in contrast to dynamic testing. It is generally not detailed testing, but checks mainly for the sanity of the code, algorithm, or document. It is primarily syntax checking of the code and/or manually reviewing the code or document to find errors. This type of testing can be used by the developer who wrote the code, in isolation. Code reviews, inspections and walkthroughs are also used.

EDIT: One of the many sources that mentiones static testing to employ reviews etc. (look for "static testing" in Google books):

答:
Code reviews nowadays may, on occasion, pick up bugs. But they are more about reviewing the quality of the code rather than the quality of the product.

But there was a time when static testing -- stepping through the code with an eye to catching bugs -- was a justifiable technique. That time was when compilation was something you put in a VMS queue and waited four hours for it to run. Then you'd set up a test run and put it at the back of the same queue. Or, earlier, you'd print the code out on cards and carry them over to an operations room, expecting to be able to test it in a couple of days.

Spending an hour running through the code before (or, often, while) waiting for that was a very good idea.

Now you can compile in seconds and run instantly, so the benefits of static testing have long gone. But those days were less than 20 years ago, for some of us, and that might be why you're still seeing reference to code reviews as an application QA activity.


问:
How to structure git repositories for project?
I'm working on a content synchronisation module for Drupal.  There is a server module, which sits on ona website and exposes content via a web service.  There is a also a client module, which sits on a different site and fetches and imports the content at regular intervals.

The server is created on Drupal 6.  The client is created on Drupal 7.  There is going to be a need for a Druapl 7 version of the server.  And then there will be a need for a Drupal 8 version of both the client and the server once it is released next year.

I'm fairly new to git and source control, so I was wondering what is the best way to setup the git repositories?  Would it be a case of having a separate repository for each instance, i.e:

```<code>Drupal 6 server = 1 repository
Drupal 6 client = 1 repository
Drupal 7 server = 1 repository
Drupal 7 client = 1 repository
etc
</code>```

Or would it make more sense to have one repository for the server and another for the client then create branches for each Drupal version?

Currently I have 2 repositories - one for the client and another for the server.

答:
I have seen and worked with such variations. Everything in one folder with subfolders for server and client or one repo each. I prefer the single repo for every main part of the project.

In case of big version changes I would simply create new repos too. Definitely not have different branches for them. While branches are powerful for implementation of new functionality and maybe one permanent deployment branch, I always avoid having too many of them run parallel for a long time. You will always have to maintain them (do rebases when the master branch changed etc), so keep the basic structuring as simple as possible. Having an extra repo is (in my humble opinion) less painful than juggling branches in different states. Especially if client and server don't share much code.

I don't know much about Drupal and how strong the differences between versions are. So my point to prefer different repos is based more on my experience with Rails. Between versions there are sometimes big differences in things like how files are named or the folder structure (eg asset pipeline) which makes it more comfortable to create a new repo. Drupal (or any other framework) may have less differences, then it would be ok to just go on within the existing repo.


问:
Google review microformats, microdata, RDFa, oh my!
I'm developing a website which includes a section for reviews. I want to include Google's microformat for review information so that details of the review show up in Google's snippet thingy, like this:

However, according this page, Google supports three different formats for the review data, "microformat", "microdata" and RDFa. They all seem to do exactly the same thing, though, and I have no idea which one to choose...

RDFa looks nice - in that the data is fairly separate from the actual content (which makes my life a bit easier). Except it's based on XML namespaces, which isn't going to play well with HTML5 (the site isn't HTML5 yet, but I imagine it will be ported eventually).

The "hReview microformat" seems to use special CSS classes to denote the various sections of the review, which seems like a bad mix of concerns to me...

So I'm kind of leaning towards the "microdata" format, which looks like it's closer to the HTML5 way of doing things (i.e. no special namespaces). An example of that would be (from the page I linked above):

```<code><div>
  <div itemscope itemtype="http://data-vocabulary.org/Review">
    <span itemprop="itemreviewed">L’Amourita Pizza</span>
    Reviewed by <span itemprop="reviewer">Ulysses Grant</span> on
    <time itemprop="dtreviewed" datetime="2009-01-06">Jan 6</time>.
    <span itemprop="summary">Delicious, tasty pizza in Eastlake!</span>
    <span itemprop="description">L'Amourita serves up traditional
      wood-fired Neapolitan-style pizza, brought to your table promptly
      and without fuss. An ideal neighborhood pizza joint.</span>
    Rating: <span itemprop="rating">4.5</span>
  </div>
</div>
</code>```

But as I said, all the formats are basically the same, just slightly different... which one should I choose?

答:
microdata is part of the HTML5 spec.  That for me means a lot more future that the others.

I'd only consider RDFa if you already use some RDF infrastructure. In that case, RDFa is just another serialization of semantic data.

ContentLicense: CC BY-SA 2.5


答:
I've never heard of the term "static testing". I have only heard of the term "static analysis", which refers to any time a work product is examined without being used. This includes code reviews as well as using tools such as lint, FindBugs, PMD, and FxCop.

Here is some information from sources that I have available:

Section 5 (Software Testing) of the Guide to the Software Engineering Body of Knowledge does not reference "static testing". It refers to "static software quality management techniques" described in Section 11 (Software Quality). Section 11 only has a single mention of tools being used to support these activities, stating that the analytic static activities may be conducted "with or without the assistance of tools".

Ian Sommerville's Software Engineering, 8th Edition's glossary specifically mentions static analysis as being a "tool-based analysis of a program's source code to discover errors and anomalies". However, in Chapter 22.3, Sommerville does refer to inspections as "one form of static analysis". There is no reference to "static testing". This book is considered one of the canonical references about the breadth of software engineering and is often cited as recommended reading before both IEEE certification exams.

Roger S. Pressman's Software Engineering: A Practitioner's Approach, 6th Edition makes no references to static analysis or static testing that I could find in the index or the chapters on testing.

Steve McConnell's Code Complete, 2nd Edition makes no specific references to either static analysis or static testing. However, Chapter 30.2 has a section about analyzing code quality. Tools to automatically check syntax and semantics are called tools that "examine the static source code to assess its quality". A specific example is Lint, which is frequently referred to as a static analysis tool by other sources.

Analysis tools can only be used to verify the product. Human reviews of artifacts can be used to perform both verification and validation. Testing that involves the software's execution can be verification, validation, or both, depending on the context. The key difference is that verification is concerned with finding mistakes and defects. In contrast, validation is concerned with ensuring the requirements adequately describe the customer/user's needs, and the work artifacts (design, implementation, and tests) correspond to the requirements (and the products that they are derived from).

Title: Inspection, code review - is it really testing?

Body:
ISTQB, Wikipedia or other sources classify verification acitivities (reviews etc.) as a static testing, yet other do not. If we can say that peer reviews and inspections are actually a kind of a testing, then a lot of standards do not make sense (consider e.g. ISO which say that validation is done by testing, while verification by checking of work products) - it should at least say dynamic testing for validation, shouldn't it?
I am completing master thesis dealing with QA and I must admit that I have never seen worse and more ambiguous and contradicting literature than in this field :/
Do you think (and if so, why) that static testing is a good and justifiable term or should we stick to testing and static checks/analysis?

Wikipedia: Static testing is a form of software testing where the software isn't actually used. This is in contrast to dynamic testing. It is generally not detailed testing, but checks mainly for the sanity of the code, algorithm, or document. It is primarily syntax checking of the code and/or manually reviewing the code or document to find errors. This type of testing can be used by the developer who wrote the code, in isolation. Code reviews, inspections and walkthroughs are also used.

EDIT: One of the many sources that mentiones static testing to employ reviews etc. (look for "static testing" in Google books):

ContentLicense: CC BY-SA 4.0


答:
Unless the project is really huge, I'd go for single repository with subdirectories for server and client and create a branch for each version. You can still have multiple copies of the repository in case you want access multiple versions at the same time.

By maintaining multiple repositories, you'd make transferring changes harder than necessary (rebase is easier than applying patches). In the (improbable) case there'll no changes to be applied to multiple versions, you still lose nothing...

Moreover, you can always switch to multiple repositories: Just clone the repo and remove the branches you don't want. Going the other way round is harder.

I'd go for multiple repos only if the server and client share nothing or if the code is really huge.

Title: How to structure git repositories for project?

Body:
I'm working on a content synchronisation module for Drupal.  There is a server module, which sits on ona website and exposes content via a web service.  There is a also a client module, which sits on a different site and fetches and imports the content at regular intervals.

The server is created on Drupal 6.  The client is created on Drupal 7.  There is going to be a need for a Druapl 7 version of the server.  And then there will be a need for a Drupal 8 version of both the client and the server once it is released next year.

I'm fairly new to git and source control, so I was wondering what is the best way to setup the git repositories?  Would it be a case of having a separate repository for each instance, i.e:

```<code>Drupal 6 server = 1 repository
Drupal 6 client = 1 repository
Drupal 7 server = 1 repository
Drupal 7 client = 1 repository
etc
</code>```

Or would it make more sense to have one repository for the server and another for the client then create branches for each Drupal version?

Currently I have 2 repositories - one for the client and another for the server.


问:
As a solo programmer, of what use can Gerrit be?
Disclaimer: I'm aware of the questions How do I review my own code? and What advantages do continuous integration tools offer on a solo project?. I do feel that this question aims at a different set of answers though, as it is about a specific software, and not about general musings about the use of this or that practice or tech stack.

I'm a solo programmer for an Eclipse RCP-based project. To be able to control myself and the quality of my software, I'm in the process of setting up a CSI stack. In this, I follow the Eclipse Common Build Infrastructure guidelines, with the exception that I will use Jenkins rather than Hudson. Sticking to these guidelines will hopefully help me in getting used to the Eclipse way of doing things, and I hope to be able to contribute some code to Eclipse in the future.

However, CBI includes Gerrit, a code review software. While I think it's really helpful for teams, and I will employ it as soon as the team grows to at least two developers, I'm wondering how I could use it while I'm still solo.

Question: Is there a use case for Gerrit that takes into account solo developers?

Notes: I can imagine reviewing code myself after a certain amount of time to gain a little distance to it. This does complicate the workflow though, as code will only be built once it's been passed through code review. This might prove to be a "trap" as I might be tempted to quickly push bad code through Gerrit just to get it built. I'm very interested in hearing how other solo devs have made use of Gerrit.

答:
For a single person I would consider Gerrit (which is awesome in bigger teams) to be unnecessary busywork. Yes, you could plug the verification by Jenkins into Gerrit to avoid merging broken code, but you should in principle be able to do to with Jenkins alone.

As long as Jenkins builds all your branches and runs the tests for them you should be fine by just checking it manually before merging. I personally use git-builder to do this and am happy with it.


问:
Should I incorporate exit cost into choosing a solution
I'm currently choosing between two viable software designs/solutions. Solution 1 is easy to implement, but will lock some data in a proprietary format, and will be hard to change later. Solution 2 is hard to implement, but will be a lot easier to change later on.

Should I go YAGNI on this or should I incorporate the exit cost in the decision making? Or asked differently, is the exit cost part of the TCO?

I'm thinking of going back to the customer with this to ask whether or not he thinks the exit costs are relevant, but I'd like to know what the community thinks first.

P.S. Is exit cost the correct term?

答:
If you are not 95 % sure it will be changed in future - Solution 1 - YAGNI =)

Surely it depends on your customers, and on your experience programming something for this customer.


答:
The advantage of a code review is to have another developer (preferably someone else familiar with the goals of the project) look at your work to find things that you missed. Working alone, you don't have anyone who can do that, so tools like Gerrit don't really add value.

However, it might be possible to incorporate additional tooling into your build process to help you find potential problems sooner. Consider some kind of precommit hooks to do things like code formatting against some style rules, static analysis tools like Google CodePro Analytix, FindBugs, and PMD (FindBugs and PMD can be integrated into Jenkins and Hudson), and JUnit test cases. If you're diligent in the quality of your unit and integration tests and pay attention to warnings generated by static analysis tools, you might find some of the issues that another developer might find in a code review.

Title: As a solo programmer, of what use can Gerrit be?

Body:
Disclaimer: I'm aware of the questions How do I review my own code? and What advantages do continuous integration tools offer on a solo project?. I do feel that this question aims at a different set of answers though, as it is about a specific software, and not about general musings about the use of this or that practice or tech stack.

I'm a solo programmer for an Eclipse RCP-based project. To be able to control myself and the quality of my software, I'm in the process of setting up a CSI stack. In this, I follow the Eclipse Common Build Infrastructure guidelines, with the exception that I will use Jenkins rather than Hudson. Sticking to these guidelines will hopefully help me in getting used to the Eclipse way of doing things, and I hope to be able to contribute some code to Eclipse in the future.

However, CBI includes Gerrit, a code review software. While I think it's really helpful for teams, and I will employ it as soon as the team grows to at least two developers, I'm wondering how I could use it while I'm still solo.

Question: Is there a use case for Gerrit that takes into account solo developers?

Notes: I can imagine reviewing code myself after a certain amount of time to gain a little distance to it. This does complicate the workflow though, as code will only be built once it's been passed through code review. This might prove to be a "trap" as I might be tempted to quickly push bad code through Gerrit just to get it built. I'm very interested in hearing how other solo devs have made use of Gerrit.


答:
Working from your comment about the Excel file situation, I look at it as:

not changing the current format (solution 1)

versus parsing the format now, and storing it in a different format (possibly/hopefully more suitable/future-ready) (solution 1 + parsing step, a.k.a. solution 2)

I believe YAGNI applies to that parsing step; make sure you keep the knowledge about the current structure, but don't implement the parsing yet.

Additionally, the parsed data structure may not be as flexible as you think; the requirements could aso go towards storing different information/files, which would mean you have to update/expand your tables.

Title: Should I incorporate exit cost into choosing a solution

Body:
I'm currently choosing between two viable software designs/solutions. Solution 1 is easy to implement, but will lock some data in a proprietary format, and will be hard to change later. Solution 2 is hard to implement, but will be a lot easier to change later on.

Should I go YAGNI on this or should I incorporate the exit cost in the decision making? Or asked differently, is the exit cost part of the TCO?

I'm thinking of going back to the customer with this to ask whether or not he thinks the exit costs are relevant, but I'd like to know what the community thinks first.

P.S. Is exit cost the correct term?


答:
Exit cost is part of TCO (the T does stand for total), but it's difficult to nail down unless you know a priori how long the system is going to last.  In other words, if you know the system will be used for exactly one year and it will cost $52,000 to decommission it a year from now, you can be pretty confident in adding $1,000 a week to the operational budget to cover it.

That model goes out the window when you don't know the system's lifetime.  The system could, in theory, remain in use forever, which means there will be no money spent shutting it down.  Anything you factor in now will be in today's dollars, and those figures could well be meaningless five years from now because of changes in labor rates and technology that make the process easier (or harder).

You'd be best off giving your customer some idea of what's needed to transition away from the system and let them factor that into decisions about replacement when that time comes.

(And now, having written this answer, I get to vote to close this as off topic.)


答:
YAGNI is a great rule in its place, but I'm not sure it should apply in this case. You're estimating future costs here, an activity which ought to involve some consideration of future requirements changes. If you were writing the implementation it would be a different story!

I'd suggest you do the costing, but make sure that the customer understands why you've done it. If they aren't very technical don't be surprised if they say something to the effect of "it can't be a good solution if you're already thinking of using something else!"

There may be some more fine-grained aspects to consider when you're doing/presenting your cost estimates:

How likely is it the data will be migrated to another system in the future?

Is it likely that the solution vendor will alter their own data format so that it will be easier/harder to migrate the data in future? If so, will this affect your solution?

Even if you don't want to change the data later on, is there a chance that you might want to present/access it in a different way? My experience is that this is quite common!


答:
It's (S)QA, not Testing!

It doesn't actually perform any testing, so I'd be surprised why this would be treated and refered to as such. Except if you expect the reviewers to test the program along with their review of the code.


问:
What to do when issue-tracker is down?
It has happened in our team that our issue-tracker is down. Happens about once a week now (yes, wow), and there's not really much we can do to get it back up, since it's hosted by our client in a different timezone. It sometimes takes several hours for it to be operative again.

In the meanwhile, we can't really tell which issues we were working on, and in case we do, we cannot update those issues, as in moving them through the workflow, logging used hours, checking the issue's description, leaving comments, and so on.

So the question is: how can we, as a team, work in the meanwhile so that when the issue-tracker is up again, we have the least possible hassle updating it with what we've been working?

答:
Use a Local Cache

Might not work for yours, but it might be looking at whether it's a viable route to look at. Maybe you can implement a local proxy/cache for this tracker.

We used to have an SVN proxy to prevent similar issue at a company I worked for.

As pointed out in comments, you could use a local tracker. For instance Fossil is a decent tool for personal management.

Good Ol' Whiteboard & Paper

Just keep track of what you do one way or another and update. Nothing much more you can do.

Hybrid Cache-Whiteboard :)

That's a not-so-serious option, but it might work none-the-less: implement a simple facade that will screenshot the current task list and have that projected on a wall or displayed on a screen. if the remote one is down, at least you sort of still have a list.

But I'm half-joking with that one...

SCM-ed TODO

Here's another half-baked idea: have a scheduled job export a list of tasks every N hours or so to a text file, and commit them to your SCM.

Then have developers track their daily updates in a separate file named after the ID of ticket they work on.

That's also not so great, but it might be better than nothing.

Report and Complain

Obviously that's an issue that needs to be addressed, and your client needs to be made aware of the impact it has on you and your team.

Title: What to do when issue-tracker is down?


问:
What advantages do continuous integration tools offer on a solo project?
If you're doing a solo project - would you use CI tools to build from a repository? I've used Hudson and Cruise Control in a team environment, where it's essential to build as soon as anyone checks anything in.

I think the value of version control is still obvious, but do I need to build after every commit, seeing as I would just have built on my local machine, and no-one else is committing?

答:
I wouldn't say this is just a nice bonus, I'd say it's vital to high quality software engineering for us solo artists out there. Most of us will let their quality standards slip a bit if in a rush of if they think its easy enough to fix later. If you commit software in that state, you essentially have a worthless codebase stored in your source control.

If adhered to properly (that is, you don't skip the tests and you make sure it builds every time you commit) CI forces you to adhere to a higher quality standard than you would if you'd just commit it anyways.


问:
Issues with the intended behavior of a Service layer?
This analysis makes sense, and states anything that avoids code duplication and simplifies maintenance speaks for a service layer.

What is the technical behavior?

When a service client references a service, does it do so at runtime, or does it happen at compile time?

When I change something in the service layer code, will this change be automatically taken into account in all it's clients, or do they need to be individually recompiled?

How does this make sense from a testing point of view - I have working code, based on some code from a service, but if that service changes, my code might break?!

答:
Typically service references are acquired through some sort of dependency injection, not hardcoded. They may even be remote calls.

It should most definitely not be necessary to recompile clients when a service changes

Yes, definitely. That's why the service API should be narrow and explicitly specified. And see the upside too: you have broken code based on a buggy service, but if someone fixes the service now your code works!


答: Having that degree of downtime is not normal. I'd suggest using Atlassian Jira on-demand or another online issue tracker like Trello, and suggest it to the client (show it to them once you have data in it), but if the client's solution is setting you back, have your own.</p>

Title: What to do when issue-tracker is down?

Body:
It has happened in our team that our issue-tracker is down. Happens about once a week now (yes, wow), and there's not really much we can do to get it back up, since it's hosted by our client in a different timezone. It sometimes takes several hours for it to be operative again.

In the meanwhile, we can't really tell which issues we were working on, and in case we do, we cannot update those issues, as in moving them through the workflow, logging used hours, checking the issue's description, leaving comments, and so on.

So the question is: how can we, as a team, work in the meanwhile so that when the issue-tracker is up again, we have the least possible hassle updating it with what we've been working?


问:
Is it okay to use a language that isn't supported by your company for some tasks?
I work for a company that supports several languages: COBOL, VB6, C#, and Java. I use those languages for my primary work, but I often find myself coding some minor programs (e.g. scripts) in Python because I find it to be the best tool for that type of task.

For example: an analyst gives me a complex CSV file to populate some DB tables, so I use Python to parse it and create a DB script.

What's the problem?

The main problem I see is that a few parts of these quick and dirty scripts are slowly gaining importance and:

My company does not support Python

They're not version controlled (I back them up in another way)

My coworkers do not know Python

The analysts have even started to reference them in emails ("launch the script that exports..."), so they are needed more often than I initially thought.

I should add that these scripts are just utilities that are not part of the main project; they simply help to get trivial tasks done in less time. For my own small tasks they help a lot.

In short, if I were a lottery winner to be in a accident, my coworkers would need to keep the project alive without those scripts; they would spend more time fixing CSV errors by hand, for example.

Is this a common scenario? Am I doing something wrong? What should I do?

答:
You have two options:

Make it a standard

Translate into a standard tool

Depending on the organisation #1 might be challenging (after all limiting the list of standard technologies avoids a combinatorial explosion of training and support skill requirements).

The second option would help your skill set, and you might be able to find third party (and likely open source with commercially friendly licences) to do some of the hard work. E.g. a search for "LINQ to CSV" should get some useful hits.

BTW, VB6's developer tools (IDE, compiler) is unsupported (not even security fixes) so it is likely the standard needs updating anyway. (VB6 runtime is supported as part of—and included in the install—of current Windows versions). This could perhaps be used as a helper to approach #1: the standard tool set needs to up a moving target because of supplier dependencies.


问:
As a programmer, are you required to do timesheets?
Timesheets are something that I've never been fond of, but none the less something that is a requirement within my company. They don't bother me so much, but they seem to really grind some other people's gears. I suppose I have a few questions, and feedback would be great.

Are you required to do timesheets, assuming you aren't a contractor? (That is understandable to me).

What is the granularity of timesheets that you would be comfortable with or that you use? (ex: all entries must be under two hours).

Would timesheets ever factor into your reasons for not accepting a job or leaving a current one?

How has management within your organization justified timesheets if you aren't billing to a client?

答:
At my previous job I had to account for each 15 minute block of time. It was a web development company and we were each assingned tasked. Each task had a specific number of hours alloted to it. We divided the total price we charged the customer by $100/per hour to get the total hours available for the project.

If I was given 10 hours to accomplish my tasks and it took me 15 hours, then I owed the company 5 hours overtime. I used a daily planner from Franklin Covey to keep track of time.


答:
In my experience, reinvented wheels take longer to reinvent than you think, and external wheels tend to be easier to replace.  Both kinds of wheels tend to look worse once purchased than they did when you made your decision.

If you truly think that #1 is easy to implement, and are questioning how long #2 will take, I would listen to the question.  Implement #1 now, and think about the bigger design as you go.  That will help you if you later want to reinvent it.

Conversely if #1 no longer looks as easy as you thought it did, jump to #2.


问:
Is it a common practice to minimize JavaScript usage when building a website?
I've been a web developer for almost 10 years and I've gotten into the habit of trying not to use JavaScript whenever possible. I'm not talking about building web apps here, but database driven websites.

Is this a good/respected approach?

答:
I work for my state government, and as a result most of my development involves data-driven interactive websites. Queries against historical data, form submissions, things like that. We keep our Javascript to an absolute minimum, for the following reasons:

1) Validation of form inputs should always happen on the server side, never on the client side. If you attempt to validate your inputs on the client side, all a hacker has to do is create a local copy of your web page and re-write the Javascript to allow what he wants to send you (SQL injection, etc). Your validation must take place somewhere under your exclusive control, i.e. on the server.

2) Many users either turn off Javascript or use a browser that may not implement it properly. Being the government, we have to support everyone, even if they're using really REALLY old equipment.  HTML works everywhere; Javascript, not so much.  By not using Javascript in your web pages, you give them a really small footprint on the client machine, using few resources. This maximizes the number of people who can access your content. For the same reason, you shouldn't get too nutty with your CSS. Keep it simple, keep it clean, and let little old ladies see your site even if their computer was bought in 1999 (Incidentally, we do get tech support calls from people like this).

3) Javascript, being a tool favored by "web developers" rather than server-side programmers, tends to be pretty ugly. And designers (which is what web developers usually are, if you want to be honest about it) tend to not see the problem with downloading "scripts" from random places on the web. They say things like "why reinvent the wheel?" and "Not Invented Here".  So instead of writing their own code, they often just go out and grab something from another site, thinking that if it's on the internet it's fair game. There are two problems with this: A) they might inadvertently post some malicious Javascript that takes you a while to catch, and B) they might run afoul of someone's copyright, and get you sued. Both situations are to be avoided.

IN GENERAL, Javascript is a bad idea. Client side code of ANY kind is a bad idea. The client side should only contain markup language and CSS; let the server-side handle the heavy lifting.


问:
What is a useful pattern to maintaining an object state in a one to many relationship?
I am looking for a design for my application, here are the players(classes) involved.

```<code>struct Transform {
    // Uses a matrix to transform the position.
    // Also acts acts as the state of a Dialog.
    Position transform(Position p);

    //other methods.
};

struct Dialog {
     // There are multiple dialog for the user to transform the output.

     Transform& t;
     void ChangeTranformation(){t.rotate(360);}
}

struct Algorithm {
    //gives us a position based on an implementation. For example this can return points on a circle or line.

    Transform& t;
    Position m_p;
    Dialog& d;
    Position GetCurrentPosition(){ return t.transform(m_p);}

    //other methods.
}
</code>```

Properties I need:

Each algorithms has one dialog and each dialog can have many algorithms associated with it.

When the user selects an algorithm a dialog associated with that algorithm is displayed.

If the user selects a different algorithm then re-selects back the state is restored in the dialog.

Basically I want a good design pattern to maintain the state of the dialog given that many algorithms use it and they can be switched back and forth. Does anyone have any suggestions?

Here is a use case:

Dialog1 has a single edit box to control the radius.

Algorithm1 generates points on a unit circle.

Algorithm2 is the same as Algorithm1.

The user has selected Algorithm1 and entered 2 into the edit box. This will generate points on a circle of radius 2.

The user then selects Algorithm2 and enters 10 into the edit box of Dialog1. This will generate points on a circle of radius 10.

Finally Algorithm1 is selected again. The edit box of Dialog1 should show 2 and points on a circle of radius 2 should be generated.

答:
Basically I want a good design pattern to maintain the state of the
  dialog given that many algorithms use it and they can be switched back
  and forth.

Sounds like a job for Memento.

The memento pattern is a software design pattern that provides the
  ability to restore an object to its previous state...

You're trying to associate the state of a Dialog with an Algorithm. As the current algorithm is being removed, have the current it request a memento from the dialog. The memento is an opaque (from the algorithm's perspective) object that encodes the dialog's state. When the newly selected algorithm is added to the window, it gives the memento that it had previously requested (if one exists) to the dialog, and the dialog uses it to configure itself.

That said, preserving the state of the dialog is doing things backward. The purpose of a dialog box is to let the user see, and perhaps modify, the data that the program operates on. In your case, it sounds like the algorithms are part of that. When the user changes something in the dialog box, that should cause a corresponding change in the current algorithm, and said change should be stored in someplace other than the controls of the dialog box. If you organize your program that way you can let the selection of the algorithm drive the content of the dialog. This is exactly how you'd do it if you use the Model-View-Controller paradigm (or one of it's cousins). If the user changes something in the dialog, that change modifies the algorithm (i.e. the model). If the user selects a different algorithm, the current state of the new algorithm is used to set the values in the dialog.


问:
Trying to implement pre/post method code: better to use methods or a parent class?
I'm finding it difficult to frame this question so ... I want to execute code both before and after a method runs in PHP. There are, as far as I know, two ways to implement this:

Method One: pre and post methods

```<code>class Model
{
  function find($id)
  {
    $this->_precode();
    // ... do stuff
    $this->post_code();
  }
}
</code>```

Add the calls to _precode() and _postcode() to each method where I need this functionality.

Method Two: __call and method naming

```<code>class Model extends PrePost
{
  function prepost_find($id)
  {
    // ... do stuff ...
  }
}

class PrePost
{
  function __call($method,$param)
  {
    $method = "prepost_$method";
    // .. precode here ..
    $result = $this->$method($param);
    // .. postcode here ..
  }
}
</code>```

This relies on naming a method in a specific way in the inheriting class. Is there a preferred way of doing this? The call method can be made to only handle its specific cases and even defer to a child class's call if there is one.

I'm not looking for opinions; I'm looking to find out if there are valid reasons to choose one way over another.

答:
There are actually a lot more ways than you think.

Magic call method

This is code smell to me.  It's not hard to follow, and, as shown, opens up some possible coding problems for external callers of the class.  If I call $model->something(), and it doesn't exist, it'll try to run prepost__something() incorrectly.  Magic is generally hard to follow and can give you some unexpected conditions.

Explicitly calling methods

Explicit is always better, but not when it interrupts the main flow of your method.  Also - how often are you doing this? In 1 class? 10? 100?  If it's something that's repeating a lot, then you should look at another method entirely.

The big question is what sort of functionality is hiding in those pre/post functions... is it related?  Is it something like logging, debugging, etc. that isn't related at all, but needs to be executed there?

Event Driven

If they are unrelated, the best route is an event-based system.  This is very common in most popular (well written, anyway) applications/frameworks.

```<code>class Model
{
  function find($id)
  {
    $this->dispatcher->dispatch("model.find.pre", $event = new PreFindEvent($id));

    // do whatever with $event->getId()

    $this->dispatcher->dispatch("model.find.post", new PostFindEvent($id, $result));
    return $result;
  }
}
</code>```

This requires you to pass an event dispatcher component into your class (dependency injection), and manually wire all your triggered classes into the event dispatcher.  However, you can trigger behaviour in very concise classes that modify the before/after functionality that you're going for.  This can be very verbose, but it's testable, and allows you to write very modular code.  Check out Symfony's EventDispatcher component for more examples, though many other vendors offer similar functionality.

If that's too verbose for you, and you want something a little more radical, there is also

Aspect Oriented Programming

If you want to implement cross-cutting functionality (ex, logging) across several methods, then this is a very handy option.  However, the PHP support is not that great (experimental extension is required, or framework integration).

It allows you to dynamically trigger code at various points of your application WITHOUT having to explicitly add the hook points in your code.  Something like this,

```<code>aop_add_before('some_function', 'run_this');
</code>```

Arguably, this makes code execution very hard to follow, but it allows you to do some very cool things without all of the added complexity of event-based programming.  If you use something like a dependency injection container, adding AOP may be possible to it as well, though very dependent on which tools you use.

Conclusion

Those are the options.  I'd recommend event-based as that seems to be the community standard in PHP.  (Symfony, Zend, etc.) AOP is better supported in other languages (natively), and it's a little hacky in PHP at the moment.

Either way, you're heading more and more into dependency injection, and that may be a whole new can of worms to open first.

Hope this helps.  There is no right answer - it's always dependent on your current tools, and problem domain.

Body:
There are actually a lot more ways than you think.

Magic call method

This is code smell to me.  It's not hard to follow, and, as shown, opens up some possible coding problems for external callers of the class.  If I call $model->something(), and it doesn't exist, it'll try to run prepost__something() incorrectly.  Magic is generally hard to follow and can give you some unexpected conditions.

Explicitly calling methods

Explicit is always better, but not when it interrupts the main flow of your method.  Also - how often are you doing this? In 1 class? 10? 100?  If it's something that's repeating a lot, then you should look at another method entirely.

The big question is what sort of functionality is hiding in those pre/post functions... is it related?  Is it something like logging, debugging, etc. that isn't related at all, but needs to be executed there?

Event Driven

If they are unrelated, the best route is an event-based system.  This is very common in most popular (well written, anyway) applications/frameworks.

class Model
{
  function find($id)
  {
    $this->dispatcher->dispatch("model.find.pre", $event = new PreFindEvent($id));

    // do whatever with $event->getId()

    $this->dispatcher->dispatch("model.find.post", new PostFindEvent($id, $result));
    return $result;
  }
}

This requires you to pass an event dispatcher component into your class (dependency injection), and manually wire all your triggered classes into the event dispatcher.  However, you can trigger behaviour in very concise classes that modify the before/after functionality that you're going for.  This can be very verbose, but it's testable, and allows you to write very modular code.  Check out Symfony's EventDispatcher component for more examples, though many other vendors offer similar functionality.

If that's too verbose for you, and you want something a little more radical, there is also

Aspect Oriented Programming

If you want to implement cross-cutting functionality (ex, logging) across several methods, then this is a very handy option.  However, the PHP support is not that great (experimental extension is required, or framework integration).

It allows you to dynamically trigger code at various points of your application WITHOUT having to explicitly add the hook points in your code.  Something like this,

aop_add_before('some_function', 'run_this');

Arguably, this makes code execution very hard to follow, but it allows you to do some very cool things without all of the added complexity of event-based programming.  If you use something like a dependency injection container, adding AOP may be possible to it as well, though very dependent on which tools you use.

Conclusion

Those are the options.  I'd recommend event-based as that seems to be the community standard in PHP.  (Symfony, Zend, etc.) AOP is better supported in other languages (natively), and it's a little hacky in PHP at the moment.

Either way, you're heading more and more into dependency injection, and that may be a whole new can of worms to open first.

Hope this helps.  There is no right answer - it's always dependent on your current tools, and problem domain.


问:
Why create a Huffman tree per character instead of a Node?
For a school assignment we're supposed to make a Java implementation of a compressor/decompresser using Huffman's algorithm.

I've been reading a bit about it, specially this C++ tutorial: http://www.cprogramming.com/tutorial/computersciencetheory/huffman.html

In my program, I've been thinking about having Nodes that have the following properties:

Total Frequency

Character (if a leaf)

Right child (if any)

Left child (if any)

Parent (if any)

So when building the Huffman tree, it is just a matter of linking a node to others, etc.

However, I'm a bit confused with the following quote (emphasis mine):

First, every letter starts off as part of its own tree and the trees
  are ordered by the frequency of the letters in the original string.
  Then the two least-frequently used letters are combined into a single
  tree, and the frequency of that tree is set to be the combined
  frequency of the two trees that it links together.

My question: why should I create a tree per letter, instead of just a node per letter and then do the linking later?

I have not begun coding, I'm just studying the algorithm first, so I guess I'm missing an important detail. What is it?

答:
The preceding line says: "The basic idea behind the algorithm is to build the tree bottom-up."

What the author is saying is that you start off by creating a TreeNode (or whatever you choose to call your nodes) object for each letter and then combine them in order of frequency (lowest first) to build up the final tree.

The detail you're missing is that you can think of a TreeNode as itself being a tree.


问:
Can notes/to-dos in code comments sent to code-reviews result in an effective refactoring process?
I want to start/improve a culture of collective code ownership at my company but at a geographically distributed level... I'd say there is some current collective code-ownership mentality, but only at single geographical sites.

This is a follow-up to this question: What is the politically correct way of refactoring other's code?

I'm just wondering if submitting *just code comments* for code reviews (we have ReviewBoard, possibly upgrading to Crucible) could actually be an effective mechanism to get the conversation started on improving code, without having others feel territorial about their code.

For example, if I add:

```<code>//ToDo: Refactor this code and that code because of reasons X and Y
</code>```

Then, submit it for code review, and it gets accepted... it could be considered as an agreement (which I think is sometimes harder to get with new code up front). At the same time, the author (and others) might have an easier time digesting and accepting the proposal; rejecting a proposal because it might break things will not longer be a valid reason and therefore the fear of making a change is lost... and at the same time, do not invest 10 hours optimizing something that no one thinks it is worth it and opposes to it just out of fear.

This is all conjecture, but I'm feeling something like this (submitting refactoring notes in code comments at the code-review process) would work. Has anyone done something like this in practice?, if so, what have been the results?

答:
In my experience this doesn't work because nobody takes these comments seriously. Nothing is funnier than seeing "TODO: get rid of this asap" and then doing svn blame and noticing that the comment has been there for almost a decade.

What you really need to do is make sure actual developer time is dedicated to refactoring, and the refactoring tasks are well defined (not open-ended). You need to present this to the manager and outline the problems as well as the business-benefit of doing it.

For example: "Implementing features X, and Y will become way easier, and will take much less time if we first refactor Z. Let's make some time to refactor Z!"


问:
Architecture advice for converting biz app from old school to new school?
I've got a WinForms business application that evolved over the past few years.  It's forms over data with a number custom UI experiences taylored to the business, so I don't think it's a candidate to port to something like SharePoint or re-write in LightSwitch (at least not without significant investment).

When I started it in 2009 I was new to this type of development (coming from more low level programming and my RDBMS knowledge was just slightly greater than what I got from school).

Thus, when I was confronted with a business model that operates on a strict monthly accounting cycle, I made the unfortunate decision to create a separate database for each accounting period.

Also, when I started I knew DataSets, then I learned Linq2Sql, then I learned EntityFramework.  The screens are a mix and match of those.

Now, after a few years developing this thing by myself I've finally got a small team.

Ultimately, I want a web front end (for remote access to more straight up screens with grids of data) and a thick client (for the highly customized interfaces).

My question is: can you offer me some broad strokes architecture advice that will help me formulate a battle plan to convert over to a single database and lay the foundations for my future goals at the same time?

Here's a screen shot showing how an older screen uses DataSets and a newer screen uses EF (I'm thinking this might make it more real for someone reading the question - I'm willing to add any amount of detail if someone is willing to help).

答:
If you're taking this thing to "the next level" and have a small team to get started with, you  will want to make sure you go back to the drawing board and cover all your bases.

Database

Take a look at what you've built in the past. You need to analyze the projects and come up with a set of features and scenarios that you need to cover. Then work on a database design that will cover these.

DAL

Once you have your database relatively locked down, get to work on what a client would need to access from the database. This would be your Data Access Layer (DAL). Create a library that handles this communication to the database, and possibly, authentication. Take into consideration the client platforms you will work with and how you will be hosting the DAL.

Will you be supporting an offline mode that will need an online sync\merge?

Will the DAL be hosted on the net\network? If so, that gives you the option of using WCF or OData?

If the clients are always connected, and a web client is a must, the DAL should be web-hosted so that all clients can use the same DAL. This doesn't mean you cannot create a new DAL in the future for one-off clients.

Client

This is where you really separate your code bases. If you want to support multiple windows technologies, you're better off using XAML as a front end (Win8\WinPhone8\WinRT XAML, Silverlight XAML, WPF XAML). However, that doesn't work for web unless you target Silverlight (Which is really a client tech). So you will have a different front-end here.

If you separate your UI from the logic code, you will really see a gain in code sharing. Read up on the MVVM (Model-View-ViewModel) pattern for what I mean. Using one of the many .NET MVVM frameworks available would help you out too. It generally geared towards XAML UI but it's concepts can help you segregate your code correctly.


答:
This seems like a cultural issue to me, so I would suggest working on the culture. As an indirect answer to your question, I've had success introducing this topic of collective code ownership and the refactoring process by starting a technical book club.

Clean Code by Bob Martin and Working Effectively with Legacy Code by Michael Feathers do a good job of exploring these topics.

Title: Can notes/to-dos in code comments sent to code-reviews result in an effective refactoring process?

Body:
I want to start/improve a culture of collective code ownership at my company but at a geographically distributed level... I'd say there is some current collective code-ownership mentality, but only at single geographical sites.

This is a follow-up to this question: What is the politically correct way of refactoring other's code?

I'm just wondering if submitting *just code comments* for code reviews (we have ReviewBoard, possibly upgrading to Crucible) could actually be an effective mechanism to get the conversation started on improving code, without having others feel territorial about their code.

For example, if I add:

```<code>//ToDo: Refactor this code and that code because of reasons X and Y
</code>```

Then, submit it for code review, and it gets accepted... it could be considered as an agreement (which I think is sometimes harder to get with new code up front). At the same time, the author (and others) might have an easier time digesting and accepting the proposal; rejecting a proposal because it might break things will not longer be a valid reason and therefore the fear of making a change is lost... and at the same time, do not invest 10 hours optimizing something that no one thinks it is worth it and opposes to it just out of fear.

This is all conjecture, but I'm feeling something like this (submitting refactoring notes in code comments at the code-review process) would work. Has anyone done something like this in practice?, if so, what have been the results?


问:
Shared Development Space
Currently the company I work in gives each developer their own development virtual machine. On this machine (Windows 7) they install the entire stack of the product (minus database) this stack is normally spread amongst multiple machines of differing OS (although moving towards windows 2008 and 2008r2)

So when a developer has a new project they are likely to be updating only a small piece of their stack and as such the rest of it can become out of date with the latest production code. The isolation from others means some issues won't be found until the code goes into shared test environments/production.

I'm suggesting a move from functional testing on these isolated machines to plugging machines into a shared environment. The goal being to move towards a deployment thats closer to production in mechanism and server type.

Developers would still make code changes on their Win7 vm and run unit/component testing locally but for functionally testing they would leverage a shared enviornment.

Does anyone else use a shared development environment like this? Are there many reasons against this sort of sandbox environment? The biggest drawback is a move away from only checking in code when you've done local functional testing to checking in after static testing.

I'm hoping an intelligent git branching strategy can take care of this for us.

答:
I'm not sure if enforcing a shared development environment is a good idea, but I would like to suggest that you are focusing on the wrong tool.

It seems to me that what you really need is a well setup dev environment with nightly builds/continuous integration and automated testing.

It wouldn't matter if I'm coding with vim in Ubuntu or with Eclipse in Windows if when I make a mistake the build/unit test system sends me an angry email that I broke something. By the same token, the said system would ensure the goal of better quality software much better than dictating a development environment.

It seems to me that whatever effort you would put towards a shared dev environment would be better spent setting up what I have described here.

Title: Shared Development Space


答:
Use a Formal Review Process

It works, if this is indeed part of a process that all members need to follow.

Meaning that when a code review is initiated, it's expected that there will be comments, and that these comments MUST be acted upon, either by discussing and discarding them or by implementing a change.

Link to your Issue Tracker for Follow-up Actions

If you want to be extra formal (which might be required depending on your environment and audit procedure), you could even open new tickets in your tracker for each required action, which can then be closed either as fixed or rejected with the necessary comments for clarification. If further reviews are needed, then open a review request (assuming you have a tool to do so). Code changes need to be verified, preferably by the original reviewer.

Beware of Crippling your Codebase

If that's not part of your process, then such comments are likely to become akin to dead-code or code-rot, and possibly leave more interrogations than answers behind.  So if you don't have a formal review process, you might want to avoid those, except if it's for personal tracking and you keep a tight tab on them. These should preferably have a short lifespan, and be acted on quickly. Or they shouldn't be TODOs and be actual code comments about what's wrong and needs to be changed if it's a major change, to serve as a warning to other developers.

I give additional reasons against (in the general case) inline action tags and useless inline comments in this answer about the use of non-documenting inline comments.

In fact, if you can and have the right tool for it, I'd suggest you avoid these for code reviews and use a code review and code annotation tool that allows to separate this from the code.

Rely on Code Review and Code Annotation Tools

It's a tricky decision to make, as sometimes you'd prefer to have everything with the code in your SCM (in fact there's even a code review tool for Eclipse that stores review comments in text files along with the source files, for instance). But for larger teams and projects it works quite well to have dedicated tools to annotate code and have extended discussions recorded somewhere, within the context of your code. You can also link them to current code-reviews, to tasks, or directly make comments on a file or a changetset.

In the screenshot above, for instance, you can see a threaded discussion directly inlined with the code to highlight a concern, and this is being done as part of a formal core review item (with the ID CR-ANERDS-8) relating to an open ticket (with the ID ANERDS-7).

Here is an example of a use case where you create a new ticket to be able to track future follow-up actions on the review. The reviewer can easily create tasks as he sifts through your code and notices shady spots.

There are numerous tools for this, but personally I tend to find FishEye and Crucible above par (and obviously working great hand in hand with JIRA, or even Confluence to link to even more detailed docs if needed).


问:
Is it Considered Good SQL practice to use GUID to link multiple tables to same Id field?
I want to link several tables to a many-to-many(m2m) table.

One table would be called location and this table would always be on one side of the m2m table.

But I will have a list of several tables for example:

Cards

Photographs

Illustrations

Vectors

Would using GUID's between these tables to link it to a single column in another table be considered 'Good Practice'? Will Mysql let me to have it automatically cascade updates and delete? If so, would multiple cascades lead to an issues?

UPDATE

I've read that GUID (a hex number)
Generally takes up more space in a database and slows queries down. However I could still generate 'unique' ids by just having the table initial's as part of the id so that the table card's id would be c0001, and then Illustrations be I001. Regardless of this change, the questions still stands.

答:
The purpose of Guid is to ensure unique values across distributed databases. For example if you are generating FooBars in 2000 separate databases you would use a Guid to guarantee they are unique without needing to cross check 2000 databases to see if the value exists. The Guid algorithm has the mac address baked into the algorithm to ensure no 2 machines generate the same value.

The downside of a Guid is it's big. That means indexes will be bigger and may not fit into memory. That means matching the Guid value is slow. Only use a Guid when you need a guid.

If the data is generated in a central location (not distributed) you will want to use an integer. Make it auto_increment.  This will keep things small on disk and memory. And matching is faster.

You are trying to use 1 mapping table for all the tables. But with that design you can't put a foreign key in the mapping table. Instead you should have a separate mapping for each.

You "could" create a Master table with Cards, Vectors, Illustrations, etc as sub-types via foreign key. Then use the master table in the mapping to location. But only do that if the things really are sub-types of a master type.


问:
Splitting big request in multiple small ajax requests
I am unsure regarding the scalability of the following model. I have little experience with large systems, big number of requests and so on but I'm trying to build some features considering scalability first.

In my scenario there is a user page which contains data for:

User's details (name, location, workplace ...)

User's activity (blog posts, comments...)

User statistics (rating, number of friends...)

In order to show all this on the same page, for a request there will be at least 3 different database queries on the back-end. In some cases, I imagine that those queries will be running quite a wile, therefore the user experience may suffer while waiting between requests.

This is why I decided to run only step 1 (User's details) as a normal request. After the response is received, two ajax requests are sent for steps 2 and 3. When those responses are received, I only place the data in the destined wrappers.

For me at least this makes more sense. However there are 3 requests instead of one for every user page view.
Will this affect the system on the long term? I'm assuming that this kind of approach requires more resources but is this trade of UX for resources a good dial or should I stick to one plain big request?

答:
My company is headed in the direction of serving up anonymous pages with javacript that goes and retrieves the user-specific information and then updates the page.

If your site goes through a heavy boot strap process for the page and each of the sections, you are quadrupaling the server load. If you can bypass the bootstrapping waste, you'll be fine. caching is a good way to do that, but you can do that with or without breaking your page up into little bits.

regardless, if you have slow queries (which seems to be your impetus), consider some query optimizations, some caching, and spinners! if a page load is expected to be slow, show a spinner with the message "loading your data....". If you can load a header & footer with this friendly message, then show it all at once, or as sections come in, the users don't mind as much. It can even make them feel important.

if you don't have caching or query optimizations, i would start there. once you have a good caching mechanism, you'll be able to use it anywhere, and that will help a lot. breaking a page up into multiple requests is a similar chunk of work, but only helps the one page, and the user still has to wait as long as before.


答:
Whether or not development should take place in a shared environment is a subtle question.  My preference is not to, simply because that scales better.  But I am also an advocate for making it as easy as possible to update the environment, and like to see it happen as often as possible.  If everyone checks in early, checks in often, and syncs up regularly, you effectively have a shared environment except without resource contention or as big a window for oopses.  If people aren't doing that, then a shared environment may help.

If devs are failing to keep their environment up to date, and then relying on deprecated behavior, that may be a symptom of a deeper problem.  Namely that devs are breaking each other's code.  In that case a shared development problem might solve the immediate problem, but could bring the underlying problem to the surface.  Be aware of that, and be aware that people may blame the shared environment because it is an easier target.

But QA should definitely take place in a shared environment.  It sounds like you're doing that.  To catch more the integration issues, I would highly recommend setting up https://wiki.jenkins-ci.org/display/JENKINS/Unit+Test to make sure that unit tests actually happen in a timely fashion, in a way that can track down problems to the commit that is at fault.  Making sure that you have enough unit test coverage to actually see problems is a second issue, but is one that is highly worthwhile to tackle.

Title: Shared Development Space

Body:
Currently the company I work in gives each developer their own development virtual machine. On this machine (Windows 7) they install the entire stack of the product (minus database) this stack is normally spread amongst multiple machines of differing OS (although moving towards windows 2008 and 2008r2)

So when a developer has a new project they are likely to be updating only a small piece of their stack and as such the rest of it can become out of date with the latest production code. The isolation from others means some issues won't be found until the code goes into shared test environments/production.

I'm suggesting a move from functional testing on these isolated machines to plugging machines into a shared environment. The goal being to move towards a deployment thats closer to production in mechanism and server type.

Developers would still make code changes on their Win7 vm and run unit/component testing locally but for functionally testing they would leverage a shared enviornment.

Does anyone else use a shared development environment like this? Are there many reasons against this sort of sandbox environment? The biggest drawback is a move away from only checking in code when you've done local functional testing to checking in after static testing.

I'm hoping an intelligent git branching strategy can take care of this for us.


答:
I've seen this happen... there were benefits, but some major drawbacks made it an unrealistic long-term solution when I saw it.

Co-ordination between testers

"Hi everyone, I need to do an IIS reset..." and the whole team waits

Regression testing branches (ie. testing against a previously released/supported build)

Unless you can host multiple versions of the software on the same hardware, you need a new environment.

Testing fixes

Dev makes a fix, and gives it to test... how do they deploy? Redploy to the shared environment? Wait until tomorrow to test it? What if it's a high priority fix? It's a simpler and safer scenario for QA to just deploy to a private environment... and if the latter is the most common scenario, it's trivial to perform especially with automated deployment.

Performance testing

You need consistent and specific hardware with consistent and specific loads (ie. no other testers on it, only simulated ones) to get repeatable and stable performance results

That said, it was a great way to hammer 1 specific build, using all testers manually testing functionality. Got the team through a couple fire drills. Long term though? It's really messy.

Title: Shared Development Space


问:
What is the most reliable session storage in PHP: Memcache, database or files?
What is the best and most safest way to handle PHP sessions. Is the best way to store sessions in:

Database (more reliable, but high bottleneck, slow speed, not good for high database usage websites)?

Memcache (super fast, but distributed more security problems, chances of loosing data when the server restarted and chances of loosing data when the cache is full)?

Files (default option, I guess slow since it reads and writes from file I/O, less security, etc).

Which method is the best? What are the problems and good things of each of those approaches?

答:
For my particular situation, I can tell you that sessions in a database is the number one cause of our server hang-ups by a good margin. our sessions table gets corrupted frequently enough that we have taken to truncating it pre-emptively.

memcache sounds attractive, but we have too many processes that clear the entire memcache, so user sessions would be cut off too frequently. and the older sessions would be cleared as memory became full... so no more permanent logins.

We'll be trying the default file-based sessions soon.

If you are worried about security of your session data, then you shouldn't put that data in the session - and don't trust the session - validate the user on every request.


问:
Should generated documentation go in version control history?
I'm against compiled stuff going into version control, specially when it comes to compiled binaries, however, my principles are now in question after adding doxygen support for a project.

Should the hundreds of files generated by doxygen go into version control?, what is the recommended practice here?, I think the ideal would be automating the process in a server that publishes that documentation at the same time, however, there is no such server now nor there will be for some time.

答:
No.

Keep everything that you need to rebuild anything else. If it's auto-generated then you can go back to any point in the history of your repository and build it again. Why keep it?


问:
Should I use title case in URLs?
We are currently deciding on a consistent naming convention across a site with multiple web applications. Historically, I've been an advocate of the 'lowercase all the letters!' when creating URLs:

```<code>http://example.com/mysystem/account/view/1551
</code>```

However, within the last year or two, specifically since I began using ASP.NET MVC & had more dealings with REST based URLs, I've become a fan of capitalizing the first letter of each section/word within the URL as it makes it easier to read (imho).

```<code>http://example.com/MySystem/Account/View/1551
</code>```

We're not in a situation where people need to read or be able to understand the URLs, so that's not a driver per se. The main thing we are after is a consistent approach that is rational and makes sense.

Are there any standards that declare it good to do one way or another, or issues that we may run into on (at least realistically modern) setups that would choose a preference over another? What is the general consensus for this debate currently?

答:
NEVER use title case for usability reason!
Imagine how many time you should spend and clicks to perform for different case URL in your MOBILE phone!

Title: Should I use title case in URLs?


答:
You don't need fancy patterns.  You need to separate the model from the user interface.  The algorithms and their current input data form the model.

The dialogs are part of the user interface.  When an algorithm is selected, the corresponding dialog is displayed, showing the current data for the algorithm.  If the user changes the data, that change is passed to the algorithm.

All you need is a one-to-one relationship between algorithms and their input data, and a many-to-one relationship between algorithms and dialogs.

Title: What is a useful pattern to maintaining an object state in a one to many relationship?

Body:
I am looking for a design for my application, here are the players(classes) involved.

```<code>struct Transform {
    // Uses a matrix to transform the position.
    // Also acts acts as the state of a Dialog.
    Position transform(Position p);

    //other methods.
};

struct Dialog {
     // There are multiple dialog for the user to transform the output.

     Transform& t;
     void ChangeTranformation(){t.rotate(360);}
}

struct Algorithm {
    //gives us a position based on an implementation. For example this can return points on a circle or line.

    Transform& t;
    Position m_p;
    Dialog& d;
    Position GetCurrentPosition(){ return t.transform(m_p);}

    //other methods.
}
</code>```

Properties I need:

Each algorithms has one dialog and each dialog can have many algorithms associated with it.

When the user selects an algorithm a dialog associated with that algorithm is displayed.

If the user selects a different algorithm then re-selects back the state is restored in the dialog.

Basically I want a good design pattern to maintain the state of the dialog given that many algorithms use it and they can be switched back and forth. Does anyone have any suggestions?

Here is a use case:

Dialog1 has a single edit box to control the radius.

Algorithm1 generates points on a unit circle.

Algorithm2 is the same as Algorithm1.

The user has selected Algorithm1 and entered 2 into the edit box. This will generate points on a circle of radius 2.

The user then selects Algorithm2 and enters 10 into the edit box of Dialog1. This will generate points on a circle of radius 10.

Finally Algorithm1 is selected again. The edit box of Dialog1 should show 2 and points on a circle of radius 2 should be generated.


问:
emacs keybindings
I read a lot about vim and emacs and how they make you much more productive, but I didn't know which one to pick. Finally when I decided to teach myself common lisp, the decision was straight forward: everybody says that there's no better editor for common lisp, than emacs + slime. So I started with emacs tutorial and immediately I ran into something that seems very unproductive to me. I'm talking about key bindings for cursor keys:

```<code>forward/backward: Ctrl+f, Ctrl+b
up/down: Ctrl+p, Ctrl+n
</code>```

I find these bindings very strange. I assume that fingers should be on their home rows (am I wrong here?), so to move cursor forward or backward I should use my left index finger and for up and down right pinky and right index fingers. When working with any of Windows IDEs and text editors to navigate text I usually place my right hand in a position so that my thumb is on the right ctrl and my index, ring and middle fingers are on the cursor keys. From this position it is very easy and comfortable to move cursor: I can do one-character moves with my 3 right fingers, or I can press ctrl with my right thumb and do word-moves instead. Also I can press shift with my left pinky and do single-character or word selections. Also it is a very comfortable position to reach PgUp, PgDn, Home, End, Delete and Backspace keys with my right hand. So I have even more navigation and selection possibilities. I understand that the decision not to use cursor keys is to allow one to use emacs to connect to remote terminal sessions, where these keys are not supported, but I still find the choice of cursor keys very unfortunate. Why not to use j, k, i, l instead? This way I could use my right hand without much finger stretching. So how is emacs more productive? What am I doing wrong?

答:
These key bindings date from the early 70's, or perhaps before.  They were intended to be mnemonic: F for forward, B for back, N for next, P for previous.

I have been using Emacs since 1976, and prefer it for almost everything except Java programming.  But I do find the control combinations tiring on a regular keyboard.  At work I use a Kinesis Contour keyboard, and rebind the keys so that control and alt are convenient to my left thumb.

The arrow keys, page up, page down, home, end, delete, and backspace should all work.

How is Emacs more productive?

What are you comparing it to?  I find Emacs more productive than other editors because:

It is highly customizable.  It is programmable at two levels: immediately with keyboard macros, or more powerfully with Emacs-Lisp.  Emacs customizations have saved me hundreds of thousands of keystrokes and hundreds of hours of tedium.

It doesn't require planning ahead.  There is no distinction between delete and cut.  To move text, you just delete it in one place, go to the other place, and yank the deleted text.

Cursor motion, search/replace, and other primitives just work better than they do in most other editors I have used.

Title: emacs keybindings


问:
Print all values in a value object
I have to debug an issue which requires me to print all the values of a Value Object that is returned by a web service call. The Value object is a complex object in the sense, it has another object as its member which in turn has another object.

Printing all the values by using get methods is cumbersome. So I was wondering if there is a way to break down the value object by any way to get to a primitive level like String or int or Date and print them all using one API?

I had a look at the below question but my prob is that I don't have access to the source code of the value object. The sources are in obfuscated jar.

https://stackoverflow.com/questions/2413001/how-to-print-values-of-an-object-in-java

答:
You are looking for one of the Apache Commons utilites.

BeanUtils.describe()

ReflectionToStringBuilder.toString()

These do slightly different things depending on what you want to do with it.

Title: Print all values in a value object


答:
What about using the MEMORY storage engine in MySQL?

It is not as fast as Memcache but has the advantage that you can use plain SQL, and you can also use the normal storage engine when it will not be needed and switch to MEMORY when the number of users/requests grows.

I'm using it for storing large amounts of statistical data in a web app which changes frequently so it is not used for handling sessions but I think it should be well suited for this purpose.

Title: What is the most reliable session storage in PHP: Memcache, database or files?

Body:
What is the best and most safest way to handle PHP sessions. Is the best way to store sessions in:

Database (more reliable, but high bottleneck, slow speed, not good for high database usage websites)?

Memcache (super fast, but distributed more security problems, chances of loosing data when the server restarted and chances of loosing data when the cache is full)?

Files (default option, I guess slow since it reads and writes from file I/O, less security, etc).

Which method is the best? What are the problems and good things of each of those approaches?


问:
Music Notation Editor - Refactoring view creation logic elsewhere
Let me preface by saying that knowing some elementary music theory and music notation may be helpful in grasping the problem at hand.

I'm currently building a Music Notation and Tablature Editor (in Javascript). But I've come to a point where the core parts of the program are more or less there. All functionality I plan to add at this point will really build off the foundation that I've created. As a result, I want to refactor to really solidify my code.

I'm using an API called VexFlow to render notation. Basically I pass the parts of the editor's state to VexFlow to build the graphical representation of the score.

(EDIT: The following diagram is outdated as I began to rework the structure, please see the update at the bottom of the post for the new diagram)
Here is a rough and stripped down UML diagram showing you the outline of my program:

In essence, a Part has many Measures which has many Notes which has many NoteItems (yes, this is semantically weird, as a chord is represented as a Note with multiple NoteItems, individual pitches or fret positions). All of the relationships are bi-directional.

There are a few problems with my design because my Measure class contains the majority of the entire application view logic.

The class holds the data about all VexFlow objects (the graphical representation of the score). It contains the graphical Staff object and the graphical notes. (Shouldn't these be placed somewhere else in the program?)

While VexFlowFactory deals with actual creation (and some processing) of most of the VexFlow objects, Measure still "directs" the creation of all the objects and what order they are supposed to be created in for both the VexFlowStaff and VexFlowNotes.

I'm not looking for a specific answer as you'd need a much deeper understanding of my code. Just a general direction to go in.

Here's a thought I had, create an MeasureView/NoteView/PartView classes that contains the basic VexFlow objects for each class in addition to any extraneous logic for it's creation? but where would these views be contained? Do I create a ScoreView that is a parallel graphical representation of everything? So that ScoreView.render() would cascade down PartView and call render for each PartView and casade down into each MeasureView, etc. Again, I just have no idea what direction to go in. The more I think about it, the more ways to go seem to pop into my head.

I tried to be as concise and simplistic as possible while still getting my problem across. Please feel free to ask me any questions if anything is unclear. It's quite a struggle trying to dumb down a complicated problem to its core parts.

UPDATE:--------------------------------------------------------------------------

So I went ahead and started refactoring with my idea from above. Here is an updated Diagram

@JW01 I understand why bi-directional relationships are potentially bad (difficult to maintain, increased complexity), however, I do believe the increased flexibility is worthwhile and I have implemented it in a maintainable way. Each notation "container" (Score, Part, Measure, Note - all contain children of some sort) inherits from Container (this relationship isn't shown in the diagram because the program I use is shitty and it looks super messy). The Container.addItem(item) method mixes in the Traversable class methods and parent property to the item added.

To me this seemed pretty clever and easy to understand. Basically, any item that gets put in a container gets extended functionality. As a mentioned in a previous comment, I may want to pull out a nice music data API out of this, which would allow for "plug-ins" to be easily created. Traversing in both directions would be particularly helpful for functionality like that. Plus these classes are small and maintainable, and unlikely to change.

However, I understand that the less things that depend on these relationships the better. So it's definitely best if I isolate this traversing functionality for use with the Selection module.

I'm noticing that my View classes are doing a lot now. Building, rendering, formatting and handling click. It would probably be wise to factor out a an abstract View module composed of a ViewBuilder, ViewFormatter, ViewRenderer, ClickBehavior?

答:
It looks like you have taken for granted that your layout of classes should be modeled on how humans percieve sheet music.  While we look at a score and think of it as divided into nice manageable chunks called measures, a computer doesn't necessarily need to do that.  It can simply percieve the music as one long stream of notes, with some lines put at equal (by some measure) intervals between/among the notes.

When I looked at your layout the first thing that popped into my head was, how does it deal with two notes spanning two measures that are tied?

You could think of the measure bars as a kind of "note", from the point of view of the code.  Since the measures are all generally equal and their positions can be mostly implied from the rest of the music, you could place a "note" to mark the beginning of the first measure and declare the time signature, and the subsequence measures can be calculated on-the-fly from there.  Then if you want to do anything fancy like place an out-of-signature measure (a measure with 2 beats in a 4/4 song, for example) or a change of signature, you place another "note" where that event happens/begins.

Also, I (mostly) know how to read sheet music but haven't used any interactive score editing software, so I don't have much basis on which to make inferences on the suitability of any particular approach.  Consider attempting to get some experience using existing reputable score editing software, for inspiration.  Also be prepared to throw away your first prototype - it may be that the only way to find out what you are doing wrong is to do it wrong first :)


问:
looking for a short explanation of fuzzy logic
I got the idea that basics of fuzzy logic is not that hard to grasp. And I got the feeling that someone might explain it to me in like 30 minutes. I understand neural networks and am able to re-create the famous Xor problem. And understand how to go just beyond it and create 3 layer networks of x nodes.

I'd like to understand fuzzy logic till a similar usefully level, in C# language. However the problem I face, is I first need to get the concept right however I see many websites who include lots of errors in their basic explaining of this. Like for example showing pictures and use different numbers as shown in pictures to calculate their problem, as if lots of people just copied stuff without noticing what they where actually writing down. While others for me go to deep in their math notation). To me that's very annoying to learn from.

For me there is no need to re-invent wheel; Aforge already got a fuzzy logic framework. So what I am looking for are some good examples, good examples like how the neural XOR problem is solved. Is there anyone such a instructional resource out there; do you know a web page, or YouTube where it is shortly explained, what would you recommend me?

Note this article comes close; but it just doesn't nail it for me. After that I downloaded a bunch of free PDF's but most are academic and hard to read for me (I'm not English and don't have a special academic math degree).

(I've been looking around a lot for this, good starter material about it is hard to find).

答:
If you are knowledgeable about neural networks, then you already know fuzzy logic. Fuzzy logic is a general, high level term for any imprecise logic - anything where predictions must be made based on a number of parameters.

Contrast this with more 'concrete' logic.

Neural networks are an implementation of fuzzy logic.


答:
Fuzzy logic is based on fuzzy set theory. In traditional set theory an element s either belongs or does not belong to a set S. In contrast, fuzzy set theory allows partial membership: an element s can belong to a fuzzy set F to some degree. More formally a fuzzy set is defined by its membership function, which assigns a degree of membership to its elements.

Fuzzy sets are useful for describing everyday concepts, such as "short people" vs. "tall people".  A person, whose height is 175 cm could be a member of the fuzzy set ShortPeople with a degree of 0.7 and, at the same time, a member of the fuzzy set TallPeople with a degree of 0.4. In other words, you can be both tall and short at the same time with different degrees of membership.  The membership values are often between 0 and 1, but they don't have to be. Unlike probabilities they do not have to add up to 1, and unlike probability density functions, the membership functions do not have to integrate to 1.

The membership function of the set ShortPeople could be a triangle centered around 150 cm, and the membership function of the set TallPeople could be centered around 185cm.  You might also define sets for ReallyShortPeople and Giants.

Union and intersection can be defined on fuzzy sets (typically as max and min of the membership values, respectively).  Thus fuzzy and and or can also be defined.

What you are talking about is fuzzy rule-based systems, that approximate some unknown function that is hard to define explicitly. In your car example the input might be how hard you press on the accelerator, and the output might the the speed of the car. You define fuzzy sets that represent how hard you press on the gas (slightly, medium, hard), and fuzzy sets that represent the speed of the car (slow, medium, fast). Then you define fuzzy rules mapping the press of the pedal to speed: slightly -> slow',medium->medium,hard->fast`.  This is your fuzzy rule-based system.

The system works in three stages: fuzzification, inference, and de-fuzzification.  First you take a "crisp" input (the exact amount of pressure applied to the pedal), and calculate its membership in the corresponding fuzzy sets.  Then you get the corresponding fuzzy value of the car speed (inference).  Finally, you need to "crispify" or "defuzzify" that value to get the actual car speed.

Title: looking for a short explanation of fuzzy logic

Body:
I got the idea that basics of fuzzy logic is not that hard to grasp. And I got the feeling that someone might explain it to me in like 30 minutes. I understand neural networks and am able to re-create the famous Xor problem. And understand how to go just beyond it and create 3 layer networks of x nodes.

I'd like to understand fuzzy logic till a similar usefully level, in C# language. However the problem I face, is I first need to get the concept right however I see many websites who include lots of errors in their basic explaining of this. Like for example showing pictures and use different numbers as shown in pictures to calculate their problem, as if lots of people just copied stuff without noticing what they where actually writing down. While others for me go to deep in their math notation). To me that's very annoying to learn from.

For me there is no need to re-invent wheel; Aforge already got a fuzzy logic framework. So what I am looking for are some good examples, good examples like how the neural XOR problem is solved. Is there anyone such a instructional resource out there; do you know a web page, or YouTube where it is shortly explained, what would you recommend me?

Note this article comes close; but it just doesn't nail it for me. After that I downloaded a bunch of free PDF's but most are academic and hard to read for me (I'm not English and don't have a special academic math degree).

(I've been looking around a lot for this, good starter material about it is hard to find).


问:
Keeping up with upstream changes while adding small fixes or even major changes
Often I need to apply some small fixes (to make them run on my environment) or even change some parts of the software (to tailor it to my needs) to software from outside. However this obviously creates problem with updating said software, even when it changes nothing related to my fix. It would be easier when the software provided integration for some kind of plugins but more often than not it doesn't.

What would be an ideal workflow regarding that? Most of the projects are git repos I pulled from outside. How should I apply my changes so that I can update painlessly? You can assume that external changes are much more often and larger than my own ones, so reviewing each one of them won't be a solution.

答:
The most straightforward way is to create a local branch in your git repository and then merge the remote changes into your branch as they arrive. If you think of the software as "my modified version of the upstream project", then this ought to make sense.

However, another option is to use quilt (summary; offical page). It is a way to manage sets of patches on top of outside software. This might make more sense if you think of the software as "the upstream project plus my changes", and every time the upstream project changes you want to get the new stuff and then apply your changes (or modify your changes to cleanly apply).


问:
Does it matter the direction of a Huffman's tree child node?
So, I'm on my quest about creating a Java implementation of Huffman's algorithm for compressing/decompressing files (as you might know, ever since Why create a Huffman tree per character instead of a Node?) for a school assignment.

I now have a better understanding of how is this thing supposed to work. Wikipedia has a great-looking algorithm here that seemed to make my life way easier. Taken from http://en.wikipedia.org/wiki/Huffman_coding:

Create a leaf node for each symbol and add it to the priority queue.

While there is more than one node in the queue:

Remove the two nodes of highest priority (lowest probability) from the queue

Create a new internal node with these two nodes as children and with probability equal to the sum of the two nodes' probabilities.

Add the new node to the queue.

The remaining node is the root node and the tree is complete.

It looks simple and great. However, it left me wondering: when I "merge" two nodes (make them children of a new internal node), does it even matter what direction (left or right) will each node be afterwards?

I still don't fully understand Huffman coding, and I'm not very sure if there is a criteria used to tell whether a node should go to the right or to the left. I assumed that, perhaps the highest-frequency node would go to the right, but I've seen some Huffman trees in the web that don't seem to follow such criteria.

For instance, Wikipedia's example image http://upload.wikimedia.org/wikipedia/commons/thumb/8/82/Huffman_tree_2.svg/625px-Huffman_tree_2.svg.png seems to put the highest ones to the right. But other images like this one http://thalia.spec.gmu.edu/~pparis/classes/notes_101/img25.gif has them all to the left. However, they're never mixed up in the same image (some to the right and others to the left).

So, does it matter? Why?

答: Left or right shouldn't matter.  It's the up or down-ness of the nodes in the tree that determines how many bits are needed to encode them.  I asked this same question on coursera a few weeks ago and Matthew Brown provided the same response.</p>


问:
As a programmer, are you required to do timesheets?
Timesheets are something that I've never been fond of, but none the less something that is a requirement within my company. They don't bother me so much, but they seem to really grind some other people's gears. I suppose I have a few questions, and feedback would be great.

Are you required to do timesheets, assuming you aren't a contractor? (That is understandable to me).

What is the granularity of timesheets that you would be comfortable with or that you use? (ex: all entries must be under two hours).

Would timesheets ever factor into your reasons for not accepting a job or leaving a current one?

How has management within your organization justified timesheets if you aren't billing to a client?

答: My company tried, but I ignored it or wrote down nonsense times for a few weeks while still getting the job done and they forgot about it.</p>


问:
What is meaning of the term "Sans" in a class name?
I was reading code of a java project where I found a class name like "UserSansXml". This class is dealing with user objects. I wanted to know the meaning of "sans".</p>

答:
'Sans' means 'without'. Think of typefaces like 'Sans-Serif'.

Without context, it's hard to speculate what 'UserSansXml' means.