Tag Info

New answers tagged

10

Route A: with logic. If you don't witness a problem and your users do, then either your perceptions or your situations differ. Keep changing your environment in small steps so that you approach that of your users. Don't forget about esoteric conditions such as time, localization, internet connections and seemingly unrelated events occurring before, during ...


-2

You should NEVER keep those things in DB. There are other places where you can store the information. Pulling data from DB is expensive and much better solution would be to store it as XML or even separate class and including that object into other classes. Then you would only need to change the code on one place AND you would avoid torturing your DB.


2

I can't think of a situation which requires relative paths A possible reason to use relative path would be to use paths related to the location of the executable (and not to the current work directory); e.g. if your executable sits in /home/will/bin/foo you would use /home/will/bin/../data/resource (which is /home/will/data/resource) for some resource ...


0

My first program (as a 15 years old teenager) was in 1974 in PL/1 on punched cards for an IBM 370/168 mainframe. My father was working at IBM and I was lucky enough to be able to go to the datacenter on Sundays. At that time, a program of several thousands of statements (i.e.punched cards) was a big program (and a heavy one too, since many thousand of ...


0

Using a Hash or GUID as Primary Key is also bad idea because it causes Index Fragmentation and frequent Page Splits.


7

This former SO article tells you how to calculate the collision probability. For SHA-1, b is 160. The number of people living in austria is below 10 millions. Even if each living person in austria is registered in a hospital with a unique person/sector ID, that just makes a collision probability of less than 3.5 x 10^-35. I guess that should be small enough ...


4

Hashes will inevitably collide if they're smaller than all possible combinations of data. See this excellent answer: http://programmers.stackexchange.com/a/145633 If primary keys are not supposed to be meaningful (human readable; containing retrievable traits of data), I would just go with GUIDs. Yes, theoretically they can collide as well, but heat ...


3

You have not specified a development environment (IDE) and mentioned in the comments that you want this to be a more conceptual problem, so here is a way to organize this that is not specific to any IDE. I have actually done this before when developing static libraries. First, you create your library project with its own makefile and ensure it compiles ...


4

Okay, first things first: you're running PHP 5.2!? There's not really much reason to stay with that other than having out of date servers, and that means it's either time to switch hosts or update your servers because PHP 5.2 has some major known security holes which aren't ever going to be fixed. This'll also give you access to a bunch of new features, the ...


1

It's worth the time to learn the log4* library, e.g., for reasons like hierarchical logging, filters, different output formats or targets (files, databases, instant messengers, ...). But it will not remove the logging statements from your code, just a good starting point. To minimize logging code, you could either try Aspect Oriented Programming, that ...


5

Yes, this is very acceptable for some more obscure features, especially when they are hidden away in the option menu. Perhaps it's nicer to disable the buttons and add some extra text "this feature on XXX and below" or "this feature works optimal on XXX and above" if it only works partial. No, this is not acceptable on a key function that takes up 75% of ...


1

If the problematic features are available via options, buttons or something similar, you could disable or hide these elements: I expect this to be less frustrating to the user than being offered a feature only to be told "doesn't work". If you know it's not going to work, then don't make it appear like it could. Disabling the option/button will allow you ...


-1

I think it depends. If you are just using a little bit of PHP to create a list via looping, it makes sense to put it in the HTML. If your PHP is extensive and is generating the bulk of the HTML, it could make sense to do HTML within PHP.


4

What about: Neither Mixing languages is not a good idea. You don't put JavaScript in HTML, or HTML in JavaScript, or JavaScript in PHP, or HTML in Python or Ruby in SQL. Why don't we do that? Because different languages usually correspond to different layers. PHP deals with business logic. HTML deals with presentation of the business objects. Thus, you ...


0

The most readable is php in html but only a little. You should split your file in two parts. Logic in the top. Here you prepare all variables but no html. In the bottom you put html with variables and a loop or two but little to no logic. Of course this doesn't scale all that well. For larger projects you should probably use a mvc framework.


1

You would have a better chance of resolving Sunni/Shite differences than you will of getting a clear answer to this sort of question. For myself, I like React's notion of components and PHP s heredoc syntax. class CompanyComponent { public function __construct($company) { $this->company = $company; } protected function ...


3

Collaboration is the reason why git is powerful! Go ahead and make your changes in a new commit. The other developer will be able to then merge your changes back into his branch and continue working on whatever extensions or changes he wants. Any merge conflicts that arise are something that he is responsible for; not you.


0

... overkill creating a class for six sided dice instead of creating a simple function generating two random numbers between 1 and 6 and returning the sum of the two. As ever, it depends. You don't say which game you're implementing, but are you only ever going to use 6-sided dice? If so, then stick with a function. If you want to go all "OO" with ...


4

I'm not a lawyer, so this should not to be considered definitive legal advice. You don't mention if there are license issues with the old code etc. So I'll assume they are proprietary. In general, all code, trademarks and IP would belong to the company A. That is what you were basically paid to do there. The knowledge remains yours, but may be subject to a ...


2

I think it would be absolutely amazing and at least some members on the Roslyn team seems to think it is a good idea. The proposed modification to the language is the ! operator and a change to the ? which could be used for reference types which could be used like. string! a;//can never be null string b;//no change string? c;//can explicitly be null The ...


2

C++ supports several programming paradigms (including); OO based techniques Generic and template programming Procedural style programming (coming from C) Using any of these techniques where is appropriate is not going to be "overkill". The broader question is more what design or pattern would be appropriate for the problem being solved, given the context ...


3

Multiple bad reviews + tons of support emails == unhappy customers. Are you going to make them happy by 'failing more gracefully' for certain conditions? Maybe. However, if I were you I'd rethink whether I released the software prematurely and I should have just fixed some of those issues before it would get in front of the customer. Update: If this is an ...


3

Is putting stack trace in files is bad? Since writing to files has nothing to do with UX, is just that security issue that makes it look bad idea? No it is not a bad thing. It is a good thing. Fatal errors need consistent and clear logs and information to attempt to reproduce the error, verify the error seen, triage, resolution and then testing. ...



Top 50 recent answers are included