Questions tagged [static-access]
in object-oriented programming, access from a static (class) context, as opposed to one from a particular object instance context
37 questions
1 vote
2 answers
2k views
Best way to access (grand grand) parent element in gui
I'm creating a multi window gui program, in c++ with Qt Widgets. I do have many custom gui elements, which usually are c++ classes inherited from QWidget or other Qt elements. When foo is the main ...
0 votes
3 answers
2k views
Usage of objects as services in static functions
The goal within my framework is to provide facades or front-facing functions/APIs so that people can easily interact with my system, as such, in most cases, that goes super well by having static ...
0 votes
1 answer
137 views
Is singleton use acceptable for static single responsibility?
I have been reading into possible design patterns and have found the use of singletons always referred to as an anti-pattern. I am currently using a singleton for the sole purpose of gathering ...
1 vote
1 answer
3k views
Should I avoid long method chaining simply to get a variable? [duplicate]
I am working on a game, and I have many instances where I have to do something like this: Game.getInstance().getEnergyDropManager().getDrops() Or: this.dimensionSelector.selectDimension(Game....
37 votes
3 answers
7k views
Why is there no static keyword in Kotlin?
Kotlin is known primarily as a drop-in replacement for Java, but it gets rid of a well-known Java construct: the static keyword. Instead, that class-level functionality is offered mainly by companion ...
5 votes
1 answer
2k views
Why shouldn't a static class have an internal state?
While working on a project, I decided to create a database class to manage my DB connection. I started looking for the best practice to do that, which is usually either a static class or a singleton ...
1 vote
1 answer
5k views
Abstract classes with static methods in PHP
Pre: I am looking at a quite big PHP project developed by a company which we need to partly interact with while building a new webapp. The whole application is developed in PHP 5. Most of the ...
0 votes
0 answers
168 views
Will this singleton style class work with accessing a session on multiple MVC controllers?
Question background: I have an e-commerce site I'm developing that requires multiple controller methods to access a single session variable. The idea: My idea was to create a singleton style class ...