• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 10:03
CEST 16:03
KST 23:03
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
TL.net Map Contest #21: Voting10[ASL20] Ro4 Preview: Descent11Team TLMC #5: Winners Announced!3[ASL20] Ro8 Preview Pt2: Holding On9Maestros of the Game: Live Finals Preview (RO4)5
Community News
BSL Team A vs Koreans - Sat-Sun 16:00 CET6Weekly Cups (Oct 6-12): Four star herO85.0.15 Patch Balance Hotfix (2025-10-8)80Weekly Cups (Sept 29-Oct 5): MaxPax triples up3PartinG joins SteamerZone, returns to SC2 competition32
StarCraft 2
General
The New Patch Killed Mech! TL.net Map Contest #21: Voting Revisiting the game after10 years and wow it's bad Stellar Fest: StarCraft II returns to Canada herO Talks: Poor Performance at EWC and more...
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament SC2's Safe House 2 - October 18 & 19 $1,200 WardiTV October (Oct 21st-31st) WardiTV Mondays RSL Offline Finals Dates + Ticket Sales!
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 495 Rest In Peace Mutation # 494 Unstable Environment Mutation # 493 Quick Killers Mutation # 492 Get Out More
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ BW caster Sayle BSL Team A vs Koreans - Sat-Sun 16:00 CET BW General Discussion Question regarding recent ASL Bisu vs Larva game
Tourneys
[ASL20] Semifinal B SC4ALL $1,500 Open Bracket LAN [Megathread] Daily Proleagues [ASL20] Semifinal A
Strategy
Current Meta BW - ajfirecracker Strategy & Training Relatively freeroll strategies Siegecraft - a new perspective
Other Games
General Games
Stormgate/Frost Giant Megathread Dawn of War IV Path of Exile Nintendo Switch Thread ZeroSpace Megathread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
Things Aren’t Peaceful in Palestine US Politics Mega-thread Russo-Ukrainian War Thread Men's Fashion Thread Sex and weight loss
Fan Clubs
The herO Fan Club! The Happy Fan Club!
Media & Entertainment
Series you have seen recently... Anime Discussion Thread [Manga] One Piece Movie Discussion!
Sports
Formula 1 Discussion 2024 - 2026 Football Thread MLB/Baseball 2023 NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
The Heroism of Pepe the Fro…
Peanutsc
Rocket League: Traits, Abili…
TrAiDoS
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1518 users

The Big Programming Thread - Page 927

Forum Index > General Forum
Post a Reply
Prev 1 925 926 927 928 929 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
TMG26
Profile Joined July 2012
Portugal2017 Posts
Last Edited: 2017-12-07 21:50:25
December 07 2017 21:49 GMT
#18521
All things considered: object oriented programming is cancer. Stick either to procedural (closer to hardware) or functional(math reliability).
Supporter of the situational Blink Dagger on Storm.
sc-darkness
Profile Joined August 2017
856 Posts
December 07 2017 22:14 GMT
#18522
Object-oriented programming is completely fine. You just need to know when there is an exception and you shouldn't follow it too strictly. Could you be more specific what your problem is?
TMG26
Profile Joined July 2012
Portugal2017 Posts
December 07 2017 22:54 GMT
#18523
Everything. Trying to hide both hardware and math under the desguise of 'domain'. Hiding file globals under the desguise of instace variables. Promises of reusabile that were never kept. Idiot ways of handling state.
It's pros are 'easyness to understand' and 'mapping to domain' which are both full of crap. Easyness to understand is a falacy, peopele start to apply real world logic to computers which never cared about it, and don't get the realiabilty of good old math. This meme of easyness makes sure that OOP code is full of bad practices from programmers that didn't understood neither CS math concepts or the underlying hardware. And abstracting to domain is crap, you should abstract math concepts, xenturies old categories used by everyone which makes the code actually reusable, rather than looking reusable.
Old full OOP languages are full of bad legacy stuff given by the necessary OOP things of the time and ignorance of math concepts. Then there is the whole 'adding OOP stuff' to languages that never needed it.
I'm a bit drunk so I not gonna expand more. I dobhave more complains about it, and OOP is what I do for a living! I mainly devolep in Java and ruby, with some bash scripting for the whole CI/CD thing to work. All my hobby work is eiher in Haskell, C, Erlang and shell scripting though...

Here's a nice list of quotes from relevant people:
http://harmful.cat-v.org/software/OO_programming/

A warning the site is full of very extremist opinions in more than just software, something that is interesting because!it makes you think.
Supporter of the situational Blink Dagger on Storm.
TMG26
Profile Joined July 2012
Portugal2017 Posts
December 07 2017 23:01 GMT
#18524
http://harmful.cat-v.org/software/OO_programming/why_oo_sucks

This is apparently by Joe Armstrong, need to confirm that tough, but I'm not surprised.
Supporter of the situational Blink Dagger on Storm.
Excludos
Profile Blog Joined April 2010
Norway8125 Posts
Last Edited: 2017-12-07 23:04:17
December 07 2017 23:01 GMT
#18525
On December 08 2017 06:49 TMG26 wrote:
All things considered: object oriented programming is cancer. Stick either to procedural (closer to hardware) or functional(math reliability).


WAT... It literally revolutionised how we program, making things modular, readable, fixable and expandable. Either there's a joke I'm not getting or someone has fallen off the wagon this morning. I can only ever imagine anyone not liking OO programming have never done full stack or worked on a large software made by tens to hundreds of people over several years, or is just too used to their outdated ways (Yeah, I know. OO isn't exactly a new thing, so when I say outdated I really mean it)
sc-darkness
Profile Joined August 2017
856 Posts
Last Edited: 2017-12-07 23:06:24
December 07 2017 23:04 GMT
#18526
On December 08 2017 08:01 Excludos wrote:
Show nested quote +
On December 08 2017 06:49 TMG26 wrote:
All things considered: object oriented programming is cancer. Stick either to procedural (closer to hardware) or functional(math reliability).


WAT... It literally revolutionised how we program, making things modular, readable, fixable and expandable. Either there's a joke I'm not getting or someone has fallen off the wagon this morning. I can only ever imagine anyone not liking OO programming have never done full stack or is just too used to their outdated ways (Yeah, I know. OO isn't exactly a new thing, so when I say outdated I really mean it)


Yes, UI design patterns such as MVC and MVVM come to mind. Without them, it's a total mess to understand and maintain.
Also, I'm not aware that you can represent data structures without OOP. At some point, even in C, you will have to refer to a struct and this is when it becomes object-oriented. Yes, C structs don't have access modifiers and stuff, but struct is still very close to OOP.
TMG26
Profile Joined July 2012
Portugal2017 Posts
December 07 2017 23:17 GMT
#18527

Also, I'm not aware that you can represent data structures without OOP. At some point, even in C, you will have to refer to a struct and this is when it becomes object-oriented. Yes, C structs don't have access modifiers and stuff, but struct is still very close to OOP.

Nope.
Structs = Data representation
Objects = data + how to use that data. OOP is defining by having objects only and their only interaction is by passing 'messages'. Our so called methods. That is purest OOP.

Sure you can put mimic OOP in C by putting function pointers on structs, but that is forcing it.
Supporter of the situational Blink Dagger on Storm.
TMG26
Profile Joined July 2012
Portugal2017 Posts
December 07 2017 23:17 GMT
#18528
On December 08 2017 08:01 Excludos wrote:
making things modular, readable, fixable and expandable.

All of those existed before OOP and OOP didn't impreve any.

Supporter of the situational Blink Dagger on Storm.
sc-darkness
Profile Joined August 2017
856 Posts
December 07 2017 23:19 GMT
#18529
On December 08 2017 08:17 TMG26 wrote:
Show nested quote +

Also, I'm not aware that you can represent data structures without OOP. At some point, even in C, you will have to refer to a struct and this is when it becomes object-oriented. Yes, C structs don't have access modifiers and stuff, but struct is still very close to OOP.

Nope.
Structs = Data representation
Objects = data + how to use that data. OOP is defining by having objects only and their only interaction is by passing 'messages'. Our so called methods. That is purest OOP.

Sure you can put mimic OOP in C by putting function pointers on structs, but that is forcing it.


That's what I mean. Class is an entity which consists of state and behaviour. Struct can give you that - data and function pointers. As noted earlier, you can't have encapsulation, inheritance in non-hacky way, etc, but you're not massively away from OOP.
TMG26
Profile Joined July 2012
Portugal2017 Posts
December 07 2017 23:28 GMT
#18530
Just because OOP is possible in C doesn't mean C is OOP.
And encapsulation wasn't started by OOP, it was just called scope and modules in other paradigms.

OOP I just the bad practice of binding data and behaviour so you could try and maintain the sin of changing state. State change ia aome that should only be done for performance reason and be put away in their little corner. Only now with the comming of high concurrent services are OOP programmers starting to get why state is evil.
And binding state and behavihour and hiding it under a single file is proprably archivable in any general purpose language, functunal or procedural... So I guess you can use OOP in any language.
Supporter of the situational Blink Dagger on Storm.
waffelz
Profile Blog Joined June 2012
Germany711 Posts
Last Edited: 2017-12-07 23:50:00
December 07 2017 23:49 GMT
#18531
Whenever a debate whether OOP is bad or not comes up I feel like it stems from the misunderstanding that OOP is OOP in the most extreme form where in reality OOP ranges from the extreme example where you start discussions who really should the messenger be, should a message send itself and what not to the very basic concept of divide et impera. In general I really can't see how anyone seriously can dismiss OOP as a whole and making the claim that OOP is just popular because it was hyped, while also following an extreme hype (usually procedural these days) seems pretty ironic to me.

OOP is way too much of a proven concept to be bad in general, just like any other concept (like said procedural) which has been around for some time while also being able to deflect most criticism. It is almost as fruitless of a discussion as discussions regarding the need for certain programming languages since the person arguing against a certain language/concept/paradigm usually do so use an unreasonable or extreme example (like I hinted at with some of the bizarre discussions you can come up with in design when someone follows OOP like a religion), or one that is one that is (often specifically) not the intended use of said concept/language.

Yes, OOP isn’t the “be all end all”, but I haven’t really heard anyone notable seriously state so. Responding to the link, I would also like to add that I am pretty sure no one tries to claim that OOP is easier to learn. At least to me everyone I ever dealt with admitted that OOP forces you to learn a bit more in the beginning (compared to just hacking away), but it pays off in the long run. Not saying that OOP is the only way to do so, but I feel like for any reasonable person, the concept of OOP is like a programming language: a tool to be used when it is appropriate for the task ahead.
RIP "The big travis CS degree thread", taken from us too soon | Honourable forum princess, defended by Rebs-approved white knights
Neshapotamus
Profile Blog Joined May 2006
United States163 Posts
December 08 2017 06:04 GMT
#18532
I used to be an advocate of OOP, but have since lost that attitude after learning about different styles of programming. OOP is closely tied to imperative programming. Imperative programming is good for the reason that its the closest to hardware and makes code really fast. However, it comes at a disadvantage that the program is harder to reason about. My switch really came about after I learned functional programming in Scala. I am now an exponent of haskell, scala and basically any functional programming language. A lot of people who make arguments that OOP is great normally don't take the time to learn the new paradigm such as functional programming. It is fundamentally rooted in math. The way you apply math is fundamentally different than the way you write imperative code.

For ex:
Math:
x = 1
x = x + 1 ( this would be considered invalid in math)
You have been trained your whole life in math classes that the above statement is incorrect, but for some reason, in an imperative setting, this is ok? This is why I say that reasoning about imperative programs is hard.

I am sure you are all polyglot programmers. You should have all noticed how all imperative languages started adding functional concepts into their programming language.

Some examples:
C# - LINQ and lambda's, anonymous functions, anonymous classes.

Java - Java 8 introduced first class syntax for functional programming. Did you also notice that hamcrest is fully functional? Or notices that the new LocalDateTime and LocalDate classes are fully functional? Did you notice that your Mock libraries are also fully functional?

TMG26 - those quotes are great. I am going to start using them.
bo1b
Profile Blog Joined August 2012
Australia12814 Posts
Last Edited: 2017-12-08 06:43:43
December 08 2017 06:41 GMT
#18533
Since I learned haskell just recently I tend to agree, though I really, really like low level close to the metal languages like c and rust. Can't do that in functional programming without an awful lot of stuffing around.'

I have a dream of writing a video game engine in rust, with a haskell interpreter on top of it for really fast, really quick to code video games.
Neshapotamus
Profile Blog Joined May 2006
United States163 Posts
December 08 2017 07:09 GMT
#18534
I guess ignorance is Blisse. (sorry too ez! :p)

So, I wanted to clarify that I specifically said Dependency Injection with Inversion of Control.

Dependency Injection by itself is just another name for composition. You learn this Object-oriented programming 101. Why not just call it that instead of this fancy name?


How does dependency injection change whether an error is compile time vs runtime errors in the slightest?


Dependency Injection doesn't, but Inversion of Control does. Normally, when you are using IoC, you will normally have a container that will create and manage lifetimes of objects for you. This is when you will start having runtime errors. This can be a compile time error if object construction is made explicit at compile time.


Why does it inhibit your ability to reason about your program? I would argue the opposite, that it clarifies in the intent of your program because each dependency is explicitly laid out at a single point in your class.


Now, when you state that you have all your dependencies explicitly in one point is where I have a problem. It is much better to have your arguments at a function level, rather than at the scope of the class. When you give arguments to a function, you are basically scoping what you can use and cant use at that function. Hence it should be easier to reason about.

Mathematically, the distance I have to travel to find the scope of variables would be a good metric of complexity.

In a pure function setting, the complexity can be measured

//complexity = 0 (everything is contained in the function)
static T doSomething<T>(T t){

}


In an object-oriented setting

//complexity = 1 (because of I have to look at the scope of the object and my function is nested to figure something out)
class A<T>
private T local_t;
construct A(T t) { set local_t = t }
T doSomething<T>(){
val t = this.local_t
}
}


I have arbitrarily chosen 0 and 1, but really,
object level scope = function scope + 1 (because of the 1 level of nesting)


You don't need to switch the implementation of an object to realize the benefits of dependency injection. But you can.

We use it every day, because, at the highest level, different build flavours use different implementations of the same classes. At a lower level, it allows us to switch between mock, staging and production endpoints at run-time.


I get this all the time, that you can pass in different implementations for testing and etc.
Yes, this is true but this is what an interface is supposed to provide. The idea is not a specific to dependency injection. The whole point of an interface is to provide a set of constraints to a type.

The idea of passing in the correct implementation at runtime is what people use IoC for. This is when things go bad. It is very accessible to pass in objects and not think about the design.


This is an empty statement. Your code can always be misused. In fact, it's the other way around. Injecting allows you to establish an explicit contract that this feature will depend on this other feature. If you want to scope down a dependency, expose it as a separate interface, which can also be injected.


This is not a baseless statement. So to give some context, I am a tech lead for large organization, with over 4000 developers. I have both inherited code and created new code. I have lead teams as large at 30 developers to as small as 2 developers. I get to see a lot of bad code. This is the biggest problem that I see; People will misuse the DI framework and inject a dependency because its easy for them to get access to something. This usually creates a bad API design. I have seen 5 layers of nested dependencies instead of thinking about the problem differently. (Usually at the domain level)


These two sentences contradict each other? I'm not sure what is the point being made.

There is absolutely object construction when using DI. Not sure where you get the idea that you shouldn't make objects when you have a DI framework.


Someone made the statement that the "new" keyword should disappear when you use DI w/ IoC


In the opposite manner, people spend too much time thinking about their code and not about how it lives in the framework of the application they are writing. Once the framework is set up, DI is invisible. Annotate and put in the constructor and be done for the majority of cases, really until you want to swap implementations, which is a feature of DI, not the core.

If DI doesn't work, it's almost always that it was written with another intent in mind. Or maybe it's just wrong. Scoped DI allows you to clarify the intent of where the object lives.


I guess we have different styles of thinking. You should think about the code and how you should compose functions and build a domain specific language.

What I would suggest is learning functional programming paradigm. It has been an eye opener for me and might do the same for you.

TMG26
Profile Joined July 2012
Portugal2017 Posts
December 08 2017 09:41 GMT
#18535
On December 08 2017 15:04 Neshapotamus wrote:
I used to be an advocate of OOP, but have since lost that attitude after learning about different styles of programming. OOP is closely tied to imperative programming. Imperative programming is good for the reason that its the closest to hardware and makes code really fast. However, it comes at a disadvantage that the program is harder to reason about. My switch really came about after I learned functional programming in Scala. I am now an exponent of haskell, scala and basically any functional programming language. A lot of people who make arguments that OOP is great normally don't take the time to learn the new paradigm such as functional programming. It is fundamentally rooted in math. The way you apply math is fundamentally different than the way you write imperative code.

For ex:
Math:
x = 1
x = x + 1 ( this would be considered invalid in math)
You have been trained your whole life in math classes that the above statement is incorrect, but for some reason, in an imperative setting, this is ok? This is why I say that reasoning about imperative programs is hard.

I am sure you are all polyglot programmers. You should have all noticed how all imperative languages started adding functional concepts into their programming language.

Some examples:
C# - LINQ and lambda's, anonymous functions, anonymous classes.

Java - Java 8 introduced first class syntax for functional programming. Did you also notice that hamcrest is fully functional? Or notices that the new LocalDateTime and LocalDate classes are fully functional? Did you notice that your Mock libraries are also fully functional?

TMG26 - those quotes are great. I am going to start using them.


The tendency is keep adding functional concepts to OOP languages, but they are still tied down to retro-compatibility. That's also why I praise kotlin for just being a pragmatic new version and clean up of java instead of a completly new language. Some languages really need those clean-up, keeping adding more stuff on top of them won't solve their flaws.

About java8: it did bring some functional stuff, but it's very limited. There was this discussion of Optional being a monad or not. It apparently is a Monad like haskell's Maybe. Until you use it in practice. It isn't a Monad due to the possibility of null references in it breaking the monad laws. And the possibility of things being null in java exists since day 0 and it won't go away any time. So, even with java getting more and more functional stuff, it will never get the higher order math concepts that make functional languages like Haskell great.

Still, FP while being easier to reason, simple to do concurrency, there is always the problem of performance, you can optimize you haskell code all you want, you would be better off using a laguage closer to hardware like C.
Supporter of the situational Blink Dagger on Storm.
Manit0u
Profile Blog Joined August 2004
Poland17384 Posts
December 08 2017 10:36 GMT
#18536
On December 08 2017 15:04 Neshapotamus wrote:
I used to be an advocate of OOP, but have since lost that attitude after learning about different styles of programming. OOP is closely tied to imperative programming. Imperative programming is good for the reason that its the closest to hardware and makes code really fast. However, it comes at a disadvantage that the program is harder to reason about. My switch really came about after I learned functional programming in Scala. I am now an exponent of haskell, scala and basically any functional programming language. A lot of people who make arguments that OOP is great normally don't take the time to learn the new paradigm such as functional programming. It is fundamentally rooted in math. The way you apply math is fundamentally different than the way you write imperative code.

For ex:
Math:
x = 1
x = x + 1 ( this would be considered invalid in math)
You have been trained your whole life in math classes that the above statement is incorrect, but for some reason, in an imperative setting, this is ok? This is why I say that reasoning about imperative programs is hard.

I am sure you are all polyglot programmers. You should have all noticed how all imperative languages started adding functional concepts into their programming language.

Some examples:
C# - LINQ and lambda's, anonymous functions, anonymous classes.

Java - Java 8 introduced first class syntax for functional programming. Did you also notice that hamcrest is fully functional? Or notices that the new LocalDateTime and LocalDate classes are fully functional? Did you notice that your Mock libraries are also fully functional?

TMG26 - those quotes are great. I am going to start using them.


You know of course that in Scala everything is an object (even functions) so you're doing functional programming on objects? Can we call it functional object programming?

The same goes for other languages, like Ruby.

Anyway, you can do functional programming in most of the modern languages, some just make it hard (hard to chain, no anonymous functions/lambdas or really weird types).

Personally, I find the concepts of FP very interesting and useful even if you can't use all of its power. It definitely helps to at least try and write your code like it would be FP. I know it helped me immensely in PHP and Ruby when I stopped mutating variables whenever I could (started using much less variables in the process). This lead to much cleaner and more robust code.

Now I keep scolding our interns whenever I see them use each on enumerables (you must have a really good reason to do that if you have access to map, reduce, inject and stuff like that).
Time is precious. Waste it wisely.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2017-12-08 11:35:26
December 08 2017 11:30 GMT
#18537
On December 08 2017 16:09 Neshapotamus wrote:
I guess ignorance is Blisse. (sorry too ez! :p)

So, I wanted to clarify that I specifically said Dependency Injection with Inversion of Control.

Dependency Injection by itself is just another name for composition. You learn this Object-oriented programming 101. Why not just call it that instead of this fancy name?


It's not exactly that though, because DI involves the process of abstracting the source of the dependencies, which is another layer on top of plain composition.


Show nested quote +

How does dependency injection change whether an error is compile time vs runtime errors in the slightest?


Dependency Injection doesn't, but Inversion of Control does. Normally, when you are using IoC, you will normally have a container that will create and manage lifetimes of objects for you. This is when you will start having runtime errors. This can be a compile time error if object construction is made explicit at compile time.


I'm still not seeing this. Do you have an example in mind? If I'm understanding correctly, I don't think swapping implementations at runtime is a feature of DI or IoC or together, but I also can't see how this could be solved by object construction at compile time.

Show nested quote +

Why does it inhibit your ability to reason about your program? I would argue the opposite, that it clarifies in the intent of your program because each dependency is explicitly laid out at a single point in your class.


Now, when you state that you have all your dependencies explicitly in one point is where I have a problem. It is much better to have your arguments at a function level, rather than at the scope of the class. When you give arguments to a function, you are basically scoping what you can use and cant use at that function. Hence it should be easier to reason about.

Mathematically, the distance I have to travel to find the scope of variables would be a good metric of complexity.

In a pure function setting, the complexity can be measured

//complexity = 0 (everything is contained in the function)
static T doSomething<T>(T t){

}


In an object-oriented setting

//complexity = 1 (because of I have to look at the scope of the object and my function is nested to figure something out)
class A<T>
private T local_t;
construct A(T t) { set local_t = t }
T doSomething<T>(){
val t = this.local_t
}
}


I have arbitrarily chosen 0 and 1, but really,
object level scope = function scope + 1 (because of the 1 level of nesting)


I think here I feel there's a specific difference between object dependency and functional dependency. An object dependency tells you about the existence of a relationship between these objects, and given how we treat objects as domain models, lets you easily say, my AccountManager depends on my AccountService, LocalStorage, etc., which is very clear, IMO, regardless of lines used. And then we can consider the usages of the service function calls. And really, I find you never really care about the original object after it's been injected. The naming of the object and method call usually implicitly gives you a lot of knowledge about it, and you end up searching for the method docs or impl if necessary anyways.


Show nested quote +

You don't need to switch the implementation of an object to realize the benefits of dependency injection. But you can.

We use it every day, because, at the highest level, different build flavours use different implementations of the same classes. At a lower level, it allows us to switch between mock, staging and production endpoints at run-time.


I get this all the time, that you can pass in different implementations for testing and etc.
Yes, this is true but this is what an interface is supposed to provide. The idea is not a specific to dependency injection. The whole point of an interface is to provide a set of constraints to a type.

The idea of passing in the correct implementation at runtime is what people use IoC for. This is when things go bad. It is very accessible to pass in objects and not think about the design.


Given that DI is just one example of IoC, I feel the two here are pretty much intertwined. A non-DI approach with IoC here relies on the user explicitly coupling the new object with a dependency. With DI, this coupling is specified at a high level at certain focal points.


Show nested quote +

This is an empty statement. Your code can always be misused. In fact, it's the other way around. Injecting allows you to establish an explicit contract that this feature will depend on this other feature. If you want to scope down a dependency, expose it as a separate interface, which can also be injected.


This is not a baseless statement. So to give some context, I am a tech lead for large organization, with over 4000 developers. I have both inherited code and created new code. I have lead teams as large at 30 developers to as small as 2 developers. I get to see a lot of bad code. This is the biggest problem that I see; People will misuse the DI framework and inject a dependency because its easy for them to get access to something. This usually creates a bad API design. I have seen 5 layers of nested dependencies instead of thinking about the problem differently. (Usually at the domain level)


I work with the people who wrote a pretty important DI framework. So maybe I'm a bit biased :p I don't think we have the idea of leads at our company, but maybe 500-1000 devs? Not all of them on the same product though.

I see it both ways, people can misuse the framework, and I can't really decide whether it's developer apathy, high barrier to entry, framework complexity, or really just poor documentation and communication. Those fit on the misuse scale in different ways. I've never really personally found the dependency and design problem difficult, but I do end up cleaning up code that's been unnecessarily blown up. But that's usually when the documentation, or existing usages of DI, isn't clear.

I also don't see a problem with injecting dependencies everywhere, because in my experience, you can have smart developers who understand how to compose APIs in a clear manner, or you can restrict injection and only expose APIs downstream that you clearly specify.

Our immediate codebase is only maintained by 50 people though, so I can imagine it could get out of hand quickly, but then I usually think back on poor documentation and communication.

Show nested quote +

These two sentences contradict each other? I'm not sure what is the point being made.

There is absolutely object construction when using DI. Not sure where you get the idea that you shouldn't make objects when you have a DI framework.


Someone made the statement that the "new" keyword should disappear when you use DI w/ IoC


Yeah, I disagree with what that guy said. A better way would be, DI involves not explicitly constructing objects (via new or factory-likes), and seeing it seems problematic in a DI world.


Show nested quote +

In the opposite manner, people spend too much time thinking about their code and not about how it lives in the framework of the application they are writing. Once the framework is set up, DI is invisible. Annotate and put in the constructor and be done for the majority of cases, really until you want to swap implementations, which is a feature of DI, not the core.

If DI doesn't work, it's almost always that it was written with another intent in mind. Or maybe it's just wrong. Scoped DI allows you to clarify the intent of where the object lives.


I guess we have different styles of thinking. You should think about the code and how you should compose functions and build a domain specific language.

What I would suggest is learning functional programming paradigm. It has been an eye opener for me and might do the same for you.



I actually started with FP, thanks. Started on Scheme for way too long, then through all the C's C, C++, C#, and now Java. Some Go during the middle of that. I still like the OO languages more. FP is neatly expressive but not anymore so than I care about, as I'm more focused on clarity and intention and organization, which is where I feel the plain C-like-langs excel in.

I do think that languages should converge towards a OOP/FP hybrid though, like Java and Kotlin are turning towards, as you get to realize more of both advantages.
There is no one like you in the universe.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-12-08 18:26:48
December 08 2017 18:13 GMT
#18538
Python question:

I have an adjacency list of tuples. So, an outter list, and each element of that list is a list of tuples.

I want to sort the primary (outter list) by the following criteria.

For each inner list we have the first two tuples as (a,b),(c,d). b and d are integers. I want to take the difference of those two integers.

I then want to sort the primary list by those differences.


example:
if I had an adjacency list AL,
where AL[0] was a list that started with ("fun",5),("stuff",8)
and AL[574] started with ("crabs",9),("water",10)

then the sorting would place AL[574] before AL[0], because AL[574] has a difference of only 1, and AL[0] has a difference of 3.

I know that I could literally write my own sorting algorithm, but I am wondering if anyone knows how to use sorted well enough to tell me how to use key= to do this kind of thing, so that I can just feed it the differences and let it use it's quicksort or whatever.


edit: nevermind, figured it out like 5 minutes later.
if anyone wants to know how you do it, it's like this:


def MyFn(x):
(a,b) = x[0]
(c,d) = x[1]
return d-b

AdjList = sorted(AdjList , key=MyFn)
Manit0u
Profile Blog Joined August 2004
Poland17384 Posts
December 08 2017 20:36 GMT
#18539
On December 08 2017 07:54 TMG26 wrote:
Everything. Trying to hide both hardware and math under the desguise of 'domain'. Hiding file globals under the desguise of instace variables. Promises of reusabile that were never kept. Idiot ways of handling state.
It's pros are 'easyness to understand' and 'mapping to domain' which are both full of crap. Easyness to understand is a falacy, peopele start to apply real world logic to computers which never cared about it, and don't get the realiabilty of good old math. This meme of easyness makes sure that OOP code is full of bad practices from programmers that didn't understood neither CS math concepts or the underlying hardware. And abstracting to domain is crap, you should abstract math concepts, xenturies old categories used by everyone which makes the code actually reusable, rather than looking reusable.
Old full OOP languages are full of bad legacy stuff given by the necessary OOP things of the time and ignorance of math concepts. Then there is the whole 'adding OOP stuff' to languages that never needed it.
I'm a bit drunk so I not gonna expand more. I dobhave more complains about it, and OOP is what I do for a living! I mainly devolep in Java and ruby, with some bash scripting for the whole CI/CD thing to work. All my hobby work is eiher in Haskell, C, Erlang and shell scripting though...

Here's a nice list of quotes from relevant people:
http://harmful.cat-v.org/software/OO_programming/

A warning the site is full of very extremist opinions in more than just software, something that is interesting because!it makes you think.


What you forgot to mention is that most software is created to be used by people and that's where OOP really shines. Procedural programming is mostly used for system level programming (people hardly interact with kernel drivers directly) and functional programming is used for highly theoretical academic stuff (math proofs) and multi-threaded/asynchronous systems (telecoms come to mind).

The vast majority of software that is being built though are applications that require user interaction (games, websites, ERP systems etc.) and those benefit greatly from this "dreadful domain approach". Sure, you probably could do it "the proper way" (like people who are trying to build website frameworks in Haskell, LOL), but you must realize that the demand for such software is so high that there's constantly a shortage of developers. If you were to raise the barrier of entry to people who have at least PhD in maths and are fluent in functional programming then nothing would get done.

It's a compromise, you get less reliable systems but can build them much easier and faster (and worry about making them reliable later down the line) because what's the most important in programming is actually getting shit done, not making sure that it's "pure" or "proper".
Time is precious. Waste it wisely.
sc-darkness
Profile Joined August 2017
856 Posts
December 08 2017 21:32 GMT
#18540
On December 09 2017 05:36 Manit0u wrote:
Show nested quote +
On December 08 2017 07:54 TMG26 wrote:
Everything. Trying to hide both hardware and math under the desguise of 'domain'. Hiding file globals under the desguise of instace variables. Promises of reusabile that were never kept. Idiot ways of handling state.
It's pros are 'easyness to understand' and 'mapping to domain' which are both full of crap. Easyness to understand is a falacy, peopele start to apply real world logic to computers which never cared about it, and don't get the realiabilty of good old math. This meme of easyness makes sure that OOP code is full of bad practices from programmers that didn't understood neither CS math concepts or the underlying hardware. And abstracting to domain is crap, you should abstract math concepts, xenturies old categories used by everyone which makes the code actually reusable, rather than looking reusable.
Old full OOP languages are full of bad legacy stuff given by the necessary OOP things of the time and ignorance of math concepts. Then there is the whole 'adding OOP stuff' to languages that never needed it.
I'm a bit drunk so I not gonna expand more. I dobhave more complains about it, and OOP is what I do for a living! I mainly devolep in Java and ruby, with some bash scripting for the whole CI/CD thing to work. All my hobby work is eiher in Haskell, C, Erlang and shell scripting though...

Here's a nice list of quotes from relevant people:
http://harmful.cat-v.org/software/OO_programming/

A warning the site is full of very extremist opinions in more than just software, something that is interesting because!it makes you think.


What you forgot to mention is that most software is created to be used by people and that's where OOP really shines. Procedural programming is mostly used for system level programming (people hardly interact with kernel drivers directly) and functional programming is used for highly theoretical academic stuff (math proofs) and multi-threaded/asynchronous systems (telecoms come to mind).

The vast majority of software that is being built though are applications that require user interaction (games, websites, ERP systems etc.) and those benefit greatly from this "dreadful domain approach". Sure, you probably could do it "the proper way" (like people who are trying to build website frameworks in Haskell, LOL), but you must realize that the demand for such software is so high that there's constantly a shortage of developers. If you were to raise the barrier of entry to people who have at least PhD in maths and are fluent in functional programming then nothing would get done.

It's a compromise, you get less reliable systems but can build them much easier and faster (and worry about making them reliable later down the line) because what's the most important in programming is actually getting shit done, not making sure that it's "pure" or "proper".


Weren't you against OOP in the past? Have you changed your mind?
Prev 1 925 926 927 928 929 1032 Next
Please log in or register to reply.
Live Events Refresh
Sparkling Tuna Cup
10:00
Weekly #110
herO vs ByuNLIVE!
CranKy Ducklings419
IndyStarCraft 272
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
LamboSC2 338
IndyStarCraft 272
Railgan 77
ProTech63
MindelVK 31
StarCraft: Brood War
Horang2 1947
Barracks 1128
Soma 1009
Larva 745
ZerO 664
firebathero 468
Stork 452
Hyun 450
Mini 429
actioN 404
[ Show more ]
Light 354
sSak 255
PianO 191
hero 180
Last 138
Pusan 116
ggaemo 113
Mong 102
Backho 100
Sharp 84
Rush 69
Sea.KH 58
sorry 49
JulyZerg 42
ToSsGirL 31
Sacsri 29
zelot 27
Terrorterran 15
scan(afreeca) 11
ajuk12(nOOB) 10
Icarus 6
Dota 2
Gorgc7693
qojqva2141
Fuzer 297
Counter-Strike
olofmeister1409
Heroes of the Storm
Khaldor323
Other Games
singsing2549
B2W.Neo1162
DeMusliM380
Happy232
Hui .146
oskar112
KnowMe88
ArmadaUGS60
Trikslyr29
ZerO(Twitch)18
Organizations
StarCraft: Brood War
lovetv 10
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• Adnapsc2 16
• Gemini_19 15
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 3384
League of Legends
• Jankos3228
Upcoming Events
Safe House 2
2h 57m
IPSL
4h 57m
Sziky vs Havi
Artosis vs Klauso
Monday Night Weeklies
1d 1h
WardiTV Invitational
1d 20h
WardiTV Invitational
2 days
Tenacious Turtle Tussle
3 days
The PondCast
3 days
WardiTV Invitational
4 days
Online Event
5 days
RSL Revival
5 days
[ Show More ]
RSL Revival
5 days
WardiTV Invitational
5 days
Afreeca Starleague
6 days
Snow vs Soma
Sparkling Tuna Cup
6 days
WardiTV Invitational
6 days
Liquipedia Results

Completed

Acropolis #4 - TS2
WardiTV TLMC #15
HCC Europe

Ongoing

BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
C-Race Season 1
IPSL Winter 2025-26
EC S1
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual

Upcoming

SC4ALL: Brood War
BSL Season 21
BSL 21 Team A
BSL 21 Non-Korean Championship
RSL Offline Finals
RSL Revival: Season 3
Stellar Fest
SC4ALL: StarCraft II
CranK Gathers Season 2: SC II Pro Teams
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.