Skip to main content
Filter by
Sorted by
Tagged with
-2 votes
1 answer
60 views

I want to keep some graph traversal algorithms as generic as possible and define a protocol for this purpose: protocol Path { var distance : Int { get} var end : Node { get } init (start:...
Christophe's user avatar
  • 75.1k
Best practices
0 votes
31 replies
200 views

Does the code below violates Liskov Substitution Principle (LSP)? class Object { public: virtual ~Object() = default; }; class A : public Object { public: void print() { std::...
Dmitriano's user avatar
  • 2,474
-1 votes
1 answer
92 views

I want to type-annotate the write in a class that subclasses io.RawIOBase. I'm struggling to get anything other than Any to type check, which is frustrating, because I should be able to use a much ...
Cornelius Roemer's user avatar
0 votes
1 answer
106 views

I am trying to wrap my head around the @overload operator, generics and the Liskov Substitution Principle. I usually make my abstract classes generic on some typevar T which is followed by concrete ...
Siddhant Tandon's user avatar
-1 votes
1 answer
65 views

I believe I am trying to convert a wider type to a more narrow type, which is the opposite to the Liskov substitution principle(?) How can I tell the TS compiler that the narrowed properties "a&...
myol's user avatar
  • 10.1k
1 vote
2 answers
196 views

The Liskov substitution principle states that a piece of code should remain correct if a superclass is replaced with its subclass (paraphrasing). What I don't understand; Why do we care about this ...
ariko stephen's user avatar
1 vote
2 answers
69 views

Suppose we want to model different kinds of food; pizzas and pies. Both pizzas and pies do have a sort of topping, but their toppings are different. We implement an abstract class Baked, and two ...
magva's user avatar
  • 101
0 votes
1 answer
138 views

I'm thinking about creating an interface method with an argument that can have a mixed type, to act like metadata. I don't know the metadata type upfront, but I know that some kind of it (or something ...
Constantine's user avatar
1 vote
2 answers
112 views

The Liskov Substitution Principle (LSP) imposes four behavioral requirements on subtypes (directly from Wikipedia): Preconditions cannot be strengthened in the subtype Postconditions cannot be ...
user2978125's user avatar
3 votes
1 answer
190 views

Is the isSubstitutable property meant to specify that a class and its generalisation comply with the Liskov Substitution Principle (LSP)? If not, is there an easy way to specify LSP compliance of a ...
Christophe's user avatar
  • 75.1k
0 votes
1 answer
129 views

I'd like to share a OOP conception problem. My code is written in Python. Here is a first non-valid code snippet that illustrates my problem. Snippet 1 class Model(ABC): @abstractmethod def f(...
kouign amann's user avatar
0 votes
0 answers
50 views

I am trying to use in my project more strict type regulations. I want to use generics to enforce proper types. I've created an example (using AI) to make it clear and define my goals. I want to create ...
Paul's user avatar
  • 11
1 vote
0 answers
101 views

Suppose I have the following class: template<typename T> struct A { T* ptr; }; and a bunch of functions which take this class as a parameter, e.g.: template <typename T> int one_two_three(...
einpoklum's user avatar
  • 137k
1 vote
2 answers
125 views

The Liskov Substitution Principle (LSP) states that objects of a superclass should be able to be replaced with objects of a subclass without affecting the correctness of the program. In other words, a ...
Daniel's user avatar
  • 1,079
2 votes
2 answers
72 views

I came across this example when I was trying to learn more about LSP, I am new to the OOPs world. You can find my question after the example. The example is as follows. In mathematics, a Square is a ...
nandu's user avatar
  • 29
0 votes
1 answer
263 views

After installing the latest neovin version (0.10), I can see extra pointers of variables names. That's what I mean enter image description here So when I open a file all looks good and after loading ...
Dmitrii Moskin's user avatar
0 votes
2 answers
1k views

ZLS version is for 0.12.0 (I put in into PATH and lua script and checked if some plugin puts builtin LSP which I dont need). In config_gen/config.json: { "name": "...
varikoz272's user avatar
0 votes
1 answer
111 views

Wanted to know if I am breaking Liskov Substitution Principle - post-condition rule here, public class ProcessController { public virtual Dictionary<int, string> GetRunningProcess() { ...
riki's user avatar
  • 2,433
0 votes
0 answers
47 views

I have been going through LSP with C# and I have a few confusion. Let just say public class Employee { //properties } public class EmployeeExtendedDetail : Employee { //properties } ...
riki's user avatar
  • 2,433
0 votes
2 answers
75 views

I have been trying understand the idea of covariant along with the Liskov substitution principle with some of the examples I found in the internet. This is one the those example I am currently ...
riki's user avatar
  • 2,433
-1 votes
1 answer
147 views

I need a lisp routine to check the polygons (closed polylines) and verify if there's a block (selected by user) inside. After that, highlight the empty polygons, something like this picture. Autocad ...
Kevin. Perez's user avatar
0 votes
1 answer
184 views

I have some troubles finding real use cases of covariant/contravariant. I would like a concrete motivation and example on when covariant/contravariant is used, in particular, I would appreciate the ...
ilovewt's user avatar
  • 1,043
1 vote
0 answers
270 views

Python's type system says that list is invariant, and that List[int] is not a subtype of List[float]. Here's the Python code snippet: def append_pi(lst: List[float]) -> None: lst += [3.14] ...
ilovewt's user avatar
  • 1,043
2 votes
1 answer
90 views

What is the correct way to type hint such subclassed factories, like those in the following popular pattern? The Liskov Substitution Principle originally only applies to instances, not classes, so I ...
pchlyx's user avatar
  • 21
1 vote
1 answer
2k views

I'm using Neovim, Lua, and Lazy.nvim. I've installed nvim-lspconfig, as this screenshot proves: Proof Anyway, I wanted to use GDScript in Neovim, and this is what I ended up doing this: -- General ...
Yunky's user avatar
  • 11
1 vote
2 answers
7k views

I uncomment the lazy.lua to install tsserver and jsonls but both are failed to install. Can anybody solve this problem. I installed everything that requires to run lazy vim. Then i uncomment the list ...
Sayantan Bar's user avatar
1 vote
1 answer
1k views

I'm revisiting design patterns, especially those that I haven't used for a while/or at all. And one of them is the Prototype pattern. Different sources (e.g. this one) say that you should implement ...
sashkins's user avatar
  • 971
0 votes
1 answer
162 views

this is my lua config for cmp: require('lspconfig')['jdtls'].setup { root_dir = function(fname) return vim.fn.getcwd() end, cmd = { 'jdtls', '-vmargs', '-...
YnwrdCreso's user avatar
0 votes
1 answer
486 views

Does Liskov substitution say that refference do the other class must be in a base class not in some derived class? So inheritance and properties in case below is not right ? abstract Location // place ...
Artur's user avatar
  • 139
0 votes
0 answers
114 views

The compare (overridden) methods have different signatures than their super's compare: abstract class Person { public abstract compare(that: Person): boolean; } class Student extends Person { ...
OrenIshShalom's user avatar
5 votes
1 answer
1k views

I'm creating a custom Python CLI module using docx2pdf. The docx2pdf module is using tqdm to display progress bars while the .docx files are being converted to .pdf. In my module I'm using the CLI log ...
Timur U's user avatar
  • 445
3 votes
1 answer
645 views

I want to write Unreal Engine C++ code in Neovim, but don't how to config lsp server to enable the auto completion and formating for UE C++. Anyone who can help me out of this? Thx a lot. I want to ...
hun1982's user avatar
  • 77
1 vote
1 answer
3k views

I'm trying to set up my Neovim/LSP/Clangd setup at work. We use two different ways to store source (.cpp). and header (.h) files. The first way is the common approach, where both the source and header ...
Fanteria's user avatar
3 votes
2 answers
6k views

I am using lsp-zero which uses mason to install everything but whenever I try to install java-language-server I get the error. Any help is appreciated. Whenever i do :LspInstall and choose the first ...
Shlok V's user avatar
  • 31
0 votes
2 answers
100 views

I am trying out figure out Rascal LSP and I have it working fine but I want to enable the TypeChecker but I can’t figure out how to construct a Builder object to pass to builder function from the code ...
Benni Katchy's user avatar
1 vote
2 answers
115 views

The print function can print integers and can be called like print(5). I want to do the same on an [Int] array. However attempting to do the same on a forEach fails. [1,2,3].forEach(print) gives ...
R u c k s a c k's user avatar
1 vote
1 answer
882 views

I have an abstract parent class like: class Parent(ABC): @classmethod @abstractmethod def method(cls, *args, basepath: str = None): raise NotImplementedError() and a concrete ...
medley56's user avatar
  • 1,409
2 votes
2 answers
272 views

I am reading a book about Design Patterns, and there's this chapter on the Liskov Substitution Principle that says to do this (and other tasks) to achieve the principle: Parameter types in a method ...
matthewbolds's user avatar
-1 votes
1 answer
241 views

I was quite surprised to see that Python - at least partially - seems to violate some oo / SOLID principles. Example: class FractionTuple(tuple): def __new__(cls, p, q): # Ensure that p and q are ...
TomS's user avatar
  • 290
3 votes
0 answers
937 views

Imagine being given the following base class that you have no control over: from typing import Optional class A: def foo(self, x: Optional[bool] = None) -> None: pass Now you want to ...
Daniel Fainberg's user avatar
8 votes
0 answers
3k views

I would like pyright installed by Mason to use the current conds environment, that is the one used when opening neovim. If I put a pyrightconfig.json shown below in root dir of my project, this will ...
H.Li's user avatar
  • 371
0 votes
0 answers
111 views

I was rewriting some code to practice SOLID and I think my code is failing the Liskov Substitution Principle. I don't know if this code is correct, can someone help me? That code was created to ...
Ary Guilherme Pires Caramez's user avatar
0 votes
0 answers
42 views

How should I properly satisfy the Liskov Substitution Principle in this sample? class User(ABC): # App core logic def add_photo(self, photo: bytes, ) -> None: ... class FacebookUser(...
salius's user avatar
  • 1,110
7 votes
2 answers
6k views

How does mypy apply the Liskov substitution principle to *args, **kwargs parameters? I thought the following code should fail a mypy check since some calls to f allowed by the Base class are not ...
ppc's user avatar
  • 73
0 votes
1 answer
981 views

I have installed lsp server for python and have def like this one: def get_info_about_file(db: Session, name_of_file: str) -> schema.File: return db.query(models.File).filter(models.File.name ==...
0xActor's user avatar
  • 692
0 votes
1 answer
1k views

I have https://github.com/arnoson/monaco-lua-example right here, which is an example of connecting a language server to the monaco editor (mine is especially hosted by webview2.) https://github.com/...
Icey Tamim's user avatar
0 votes
3 answers
300 views

I'm trying to figure out the Liskov's Substitution Principle and the example of the rectangle and square doesn't really click with me. So the example for the rectangle and square goes that if you have ...
james's user avatar
  • 570
0 votes
1 answer
6k views

I am trying to install the "lsp-zero" package and I am receiving the error posted below. I am desperate after trying to figure out what is going on. Any help would be great thank you. I am ...
FredFrugal's user avatar
2 votes
2 answers
197 views

The purpose of inheritance is to inherit and extend. So my question is that if child class have more method that will it break the LSP ? So in my example I have 2 classes Rectangle and Square. Square ...
Navneet Garg's user avatar
  • 1,372
0 votes
3 answers
1k views

public async IEnumerable<ParentClass> ReadResultAsync { var results = new List<ParentClass>(); results.Add(ChildClassA); results.Add(ChildClassB); return results; } I do ...
Mina chen's user avatar
  • 1,724

1
2 3 4 5
7