New answers tagged

0

I've had great success using SQLite databases as a file format for graphics applications. Its both very reliable, and being a standard format, its contents are easily viewed/converted by external programs.


1

JSON is simple and portable. External tools won't have any problems reading or writing it. You won't have any problems yourself reading and writing the data on any architecture, which is very nice. It is also very easy to be compatible with older and newer version, often just by ignoring items that you don't understand. JSON is a bit verbose if you store a ...


2

First thing I would check is if using an existing CAD format would not be sufficient. That would not only prevent you from reinventing the wheel, but also improve the interoperability with other CAD programs. Moreover, adapting the terms of such a format like "Layers" and "Entities", instead of using terms like "layouts" and "patterns" (which have typically ...


2

Single source of truth In information systems design and theory single source of truth (SSOT), also known as single point of truth (SPOT) refers to the practice of structuring information models and associated schemata such that every data element is stored exactly once (e.g., in no more than a single row of a single table). Any possible linkages ...


4

The principle you're defending is that of a "Single Source Of Truth". The corresponding antipattern doesn't have such a general name. Violating DRY ("don't repeat yourself") is sometimes called WET ("write everything twice"). In databases, violating normal form is called denormalization (and is sometimes good practice when trading off time versus space). ...


4

The most common example of Reactive programming that I've heard about is a spreadsheet program that has computed values. Personally, I would think about a spreadsheet more as a hybrid between functional and dataflow programming, but I can see how you can think about reactively. What's asynchronous there or requires streams in that case? There is ...


0

A sliding window approach (NN is trained to use the last k values of a series) is the way to go for a feed forward neural network. Redundant input values should be removed because they can negatively affect the neural network learning ability (another benefit to removing redundant variables is faster training times): [Weight Cylinders VehicleClass Rain5 ...


0

public class EventValidator implements Validator<Event> { // Validates the whole object public boolean validate(Event e){ return validatePlayers(e) && validateCourts(e) && validateMatches(e); // and so on.... } public boolean validatePlayers(Event e) { ...


0

Starting from permutations and combinations, I think we're interested in combinations: For 30 topics, you would have the followng count of combinations for each size: (In other words there are 30 combinations of size 1, and 435 combinations of size 2 (also 435 of size 28 as it turns out)). 30 435 4060 27405 142506 593775 2035800 5852925 14307150 30045015 ...


2

I forget about absolutely any pre-check when using my model classes' setters and similar methods to add data That's the problem. Ideally you should prevent your objects to have invalid state: Don't allow instantiation with invalid state and if you must have setters and other state-changing methods, throw an exception right there. instead I let ...


3

It is OK to delegate any logic by means of composition if that logic is going to change dynamically during the execution of a program. Complex validations like the ones you explain are as good a candidate as any to be delegated to another class via composition. Remember though that validations can occur in different moments. Instantiating a concrete ...


2

What makes you say it is neglected? The bandwidth actually matters. A most common consequence is that SQL queries are often tailored to return only a small amount of data. For instance, if you need to display the names of customers who were online during the last month, instead of doing a: select * from `Customers` and filtering the results within the ...


0

If it's easy to do it with queries, do it with queries. It sounds like the whole thing should be a stored procedure. As others have said, I don't think a unit testing framework will be much help to you here.


0

Everything in computers are stored as 0 or 1 i.e. so called binary values. You can open any file and read it in binary format irrespective of the file extension. But the special logic is needed to read the file if those 0's and 1's means different to for that file. e.g. 1000001 can refer to its binary equivalent or decimal equivalent of 65 or if you want ...


0

Text files are also binary files. They are just binary files with file formats which follow certain conventions, like certain bit-sequences representing certain characters. But even those conventions aren't uniform, because there are many different character encodings, and different standards for line endings.


0

It's a matter of levels of indirection and degree of convention, as so many things in CS are. All files are stored as binary, but some (text files) are stored with a sufficiently simple binary format (a text encoding) that any of a very wide range of programs can display at least a basically correct and useful rendering of the contents that can be edited by ...


3

Obviously every file is binary when it comes down to it, since every file is stored as bytes and bits. But colloquially, binary file just means any file which is not a text file. And text file means a file which consists of characters (in some character encoding or character set) and which you can open and edit in an ordinary text editor.


0

You seem to be labouring under a misapprehension about unit testing. Good unit tests adhere to FIRST principles: Whilst this may well be a valid test of your business rules, it clearly isn't a repeatable test since the source data can change over time. What you can do is write unit tests to create various data scenarios and check that your business rules ...


1

I think you're looking for isomorphic. An "isomorphism" is a 1-to-1 structure-preserving mapping between two sets of objects. Two objects are said to be isomorphic if a given isomorphism maps them to each other. This concept usually corresponds to our intuition that the two sets are "different representations of the same thing", including the fact that ...


5

Been there, done that. First let's make something clear: That's not unit testing. Unit testing is about code. You are not runnning the tests after a code change to test if code alterations introduced a bug or unwanted behavior. Instead you want to run some routines at the end of a business day to see if some business performance indicator has met some ...


1

For many applications, you should consider putting temporary files in $XDG_RUNTIME_DIR or $XDG_CACHE_HOME (the other XDG dirs are for nontemporary files). For instructions on calculating them if they are not explicitly passed in the environment, see the XDG basedir spec or find a library that already implements that part. Note, however, that ...


0

For middleware I would put a bus in order to concentrate all the possible sources of data and offer a single interface of access. Such interface will provide VC facades. You can also implement your own bus service. And the solution of Repos already exposed could fit very well under such bus "layer/service" For View layer, as you pointed its mandatory to ...


0

I prefer using Repository Design pattern with large application, you can create repo classes that responsible for fetch data from Web Services and cached it with anyway you prefer. I prefer using abstract Factory For Web Services and its configuration Classes which will give me extensibility to switch to new service or upgrade configurations. also i will ...


-2

This is more like an alternative, but you might unlink() the file immidiately after fopen() . It depends of usage pattern of cource. Unlinking the files, if it can be done, helps for several ways: file is not seen - user not see it. file is not seen from other processes - there is not chance other process to modify the file by mistake. easy cleanup if ...


9

The previous answers, although correct, aren't valid for most large scale computer clusters. Computer clusters not always follow the standard conventions for machines, usually for good reasons, and there is no point in discussing it with the sysadmins. Your current directory is referring to the central file system, which is accessed through the network. ...


32

Should I insist saving to /tmp is the right approach and defend for any failure as "working as intended" (ie. ask your admin for proper permission access)? There are standards for this, and the best thing you can do is conform to them. POSIX, which is followed by pretty much every non-mainframe OS of any significance that you're likely to run into, has ...


9

The temp-file-directory is highly operating system/environment dependant. For example a web-servers-temp dir is seperate from the os-temp-dir for security reasons. Under ms-windows every user has its own temp-dir. you should use the createTempFile() for this if such a function is available.


125

Temporary files have to be stored into the operating system temporary directory for several reasons: The operating system makes it very easy to create those files while ensuring that their names would be unique. Most backup software knows what are the directories containing temporary files, and skips them. If you use the current directory, it could have an ...



Top 50 recent answers are included