Hot answers tagged

2

The "substitution" from LSP does not mean that the subclass ultimately behaves same as way the super class. It cannot do it always anyway, simply because it is another class. What it does mean is that the contract which is important to the code it is being injected to does not change. So, for the Folder and File there are a lot of common: Both have parent ...


1

The example given sounds like a textbook example on the basics of Abstraction in Computer Science. Wikipedia refers to it as Data Abstraction: Data abstraction enforces a clear separation between the abstract properties of a data type and the concrete details of its implementation. The abstract properties are those that are visible to client code that ...


1

If you are creative enough you can make one descend from the other and satisfy Liskov. But you would have to bend semantics, like with square and rectangle. And that would not benefit your model or make it easy to work with by folks who have a good understanding of what a square, a rectangle, a file or a folder is. You could argue that a square is a simple ...


1

I can't reliably talk about all filesystems and all platforms. But I have some experience in dealing with file allocation reflecting disk/volume/partition/region structure. The most obvious way is present in WinNT NTFS disks. (I'm not entirely sure about other win FSes). It can be easily done using userspace defragmentation API. From my point you can not ...


1

The Linux/Unix way wc -l should be much faster than pure Python solutions. Using subprocess, we can do int(subprocess.check_output(['wc', '-l', filename]).split()[0])


Only top voted, non community-wiki answers of a minimum length are eligible