Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "generic programming"
-
To all the C++ programmers who haven't read "Modern C++ Design" by Andrei Alexandrescu yet, READ IT! Its great. To me, it opened up an entirely new approach to designing classes with a whole new dimension of possibilities. And it reads really well! Sometimes I got shivers because the code was so sexy 😅😂😂14
-
The problem with my life is acceptance from others. Validation (almost wrote vladiation).
For instance, I finished my course in Advanced Java Programming a few days ago. Supposed to be a year course or some shit, finished it in two months. They told me I don't need to go to the remainder classes and I could write the examination. Got the certifications, passed with flying colours.
Well done me? No, fuck you me. "It's not through Oracle, so it's completely useless. Har har you wasted your measly salary on a course and it means nothing". You know what? Fuck you and fuck validation. I will validate myself from now on.
Anywhom, what a start to a shitty rant. Let's go over some generic points so I can finally make my avatar.
IE can suck a duck ("oooh you made it and it runs fine in every fucking browser except fucking IE - slow clap).
Chrome RAM usage can suck a duck, two times. (just generic post, don't actually give a shit - I use Firefox).
People who can't use one fucking indentation standard ("oooh two spaces, oooh three spaces, oooooh a fucking tab button... " etc) can fuck off.
That fucker who came and converted my buildings in Age of Empires with the "wolololo" priest can fuck off too.
Been reading through devRant and you know what? You guys are pretty cool5 -
Just installed linux (Ubuntu 16.04.3 LTS x64) because windows update was being a cunt, instantly, it all fell into place and I got it fully running with minecraft (using generic driver, but it actually works pretty well, don't worry I will get the proper one tomorrow) and a desktop icon for it within two hours compare to windows (update) taking 4 days to do barely any updates, not accepting java or graphics drivers, which it requires because fuck opengl with the default drivers.
Fuck windows. Hooray for linux!
Now back to programming...
Thanks for putting up with me but I just need to vent because I felt like I couldn't program (and I didn't) because of FUCKING DOOLALY WINDOWS 8!
Btw thanks to the local charity shop for introducing me to (SUSE) linux when I was like 11, giving me a hope in hell of using linux. I now have around 11 bootable linux disks and 1 bootable flash.rant all praise ubuntu hail linux ranting my fucking arse off java works fuck windows opengl by default3 -
Something that really bothers me about the oop idea of "oop allows better code reuse" is the fact that I have yet to encounter a situation where I need to reuse old code for a new project.
And the code I do want to reuse I've put into a library and made genetic anyway. Something which can easily be done with any language supporting generic programming, object oriented or otherwise.6 -
And the time has come, my gf and I are just a month away from deploying yet we still call the project "project".
Usually solutions jump in my head when programming at least once a day but I can't name the damn thing for the love of God! It's the first night since we started development I have felt clueless.
Plus I don't want to be "that guy" that just gives it a generic name, like there's already a "ratemyprofessors", professor this, teacher that, fuck that shit!
I'm brain dead.8 -
I need some opinions on Rx and MVVM. Its being done in iOS, but I think its fairly general programming question.
The small team I joined is using Rx (I've never used it before) and I'm trying to learn and catch up to them. Looking at the code, I think there are thousands of lines of over-engineered code that could be done so much simpler. From a non Rx point of view, I think we are following some bad practises, from an Rx point of view the guys are saying this is what Rx needs to be. I'm trying to discuss this with them, but they are shooting me down saying I just don't know enough about Rx. Maybe thats true, maybe I just don't get it, but they aren't exactly explaining it, just telling me i'm wrong and they are right. I need another set of eyes on this to see if it is just me.
One of the main points is that there are many places where network errors shouldn't complete the observable (i.e. can't call onError), I understand this concept. I read a response from the RxSwift maintainers that said the way to handle this was to wrap your response type in a class with a generic type (e.g. Result<T>) that contained a property to denote a success or error and maybe an error message. This way errors (such as incorrect password) won't cause it to complete, everything goes through onNext and users can retry / go again, makes sense.
The guys are saying that this breaks Rx principals and MVVM. Instead we need separate observables for every type of response. So we have viewModels that contain:
- isSuccessObservable
- isErrorObservable
- isLoadingObservable
- isRefreshingObservable
- etc. (some have close to 10 different observables)
To me this is overkill to have so many streams all frequently only ever delivering 1 or none messages. I would have aimed for 1 observable, that returns an object holding properties for each of these things, and sending several messages. Is that not what streams are suppose to do? Then the local code can use filters as part of the subscriptions. The major benefit of having 1 is that it becomes easier to make it generic and abstract away, which brings us to point 2.
Currently, due to each viewModel having different numbers of observables and methods of different names (but effectively doing the same thing) the guys create a new custom protocol (equivalent of a java interface) for each viewModel with its N observables. The viewModel creates local variables of PublishSubject, BehavorSubject, Driver etc. Then it implements the procotol / interface and casts all the local's back as observables. e.g.
protocol CarViewModelType {
isSuccessObservable: Observable<Car>
isErrorObservable: Observable<String>
isLoadingObservable: Observable<Void>
}
class CarViewModel {
isSuccessSubject: PublishSubject<Car>
isErrorSubject: PublishSubject<String>
isLoadingSubject: PublishSubject<Void>
// other stuff
}
extension CarViewModel: CarViewModelType {
isSuccessObservable {
return isSuccessSubject.asObservable()
}
isErrorObservable {
return isSuccessSubject.asObservable()
}
isLoadingObservable {
return isSuccessSubject.asObservable()
}
}
This has to be created by hand, for every viewModel, of which there is one for every screen and there is 40+ screens. This same structure is copy / pasted into every viewModel. As mentioned above I would like to make this all generic. Have a generic protocol for all viewModels to define 1 Observable, 1 local variable of generic type and handle the cast back automatically. The method to trigger all the business logic could also have its name standardised ("load", "fetch", "processData" etc.). Maybe we could also figure out a few other bits too. This would remove a lot of code, as well as making the code more readable (less messy), and make unit testing much easier. While it could never do everything automatically we could test the basic responses of each viewModel and have at least some testing done by default and not have everything be very boilerplate-y and copy / paste nature.
The guys think that subscribing to isSuccess and / or isError is perfect Rx + MVVM. But for some reason subscribing to status.filter(success) or status.filter(!success) is a sin of unimaginable proportions. Also the idea of multiple buttons and events all "reacting" to the same method named e.g. "load", is bad Rx (why if they all need to do the same thing?)
My thoughts on this are:
- To me its indentical in meaning and architecture, one way is just significantly less code.
- Lets say I agree its not textbook, is it not worth bending the rules to reduce code.
- We are already breaking the rules of MVVM to introduce coordinators (which I hate, as they are adding even more unnecessary code), so why is breaking it to reduce code such a no no.
Any thoughts on the above? Am I way off the mark or is this classic Rx?16 -
Know what really grinds my gears?
People who refer to "ajax" as though it's a separate programming language, instead of what it is, which is an old shitty method in an old shitty library. What I do enjoy is people thinking it's dish soap. That will *never* not be funny to me.
Examples:
1. *generic job description*...5 years experience. Desired skills: HTML, Foundation, PHP, Ajax, Fortran, Assembly, Tagalog, smoke signals.
2. Someone in "marketing": "Do you know Ajax?"
3. Jackass in a coffee shop who uses moustache wax: "I'm an ajax programmer. Yeah I've heard of [any recent band], like twenty years ago. They suck."
Go die, and take ajax with you.2 -
Screw Java. Spent the last two days in this language and it's driving me to fits. Tried making a generic function. Java can't seem to easily handle generic typed arrays. Java threw a fit when I converted an array function to an integer function. Java has all this stupid boilerplate code that you put on every stupid thing.
Programming in Java is about as pleasurable as running face first into a brick wall.2 -
Today a recruiter messaged me on Facebook. Week ago, I left a post with my CV on a programming group-currently I'm looking for a junior JAVASCRIPT (important ! ) /Node.js position, explicitly said so.
R(ecruiter): "Hello sir, we noticed your post with CV on group XYZ, are you still looking for a job?"
Me: "Yes, of course."
R: "We are building a new team in city X, remote work is possible. I will send you job posting right away."
Started reading it, job title is SENIOR JAVA DEVELOPER. Okay, maybe she sent me wrong document, maybe she wanted me to read just a bit about company and every job posting is pretty generic.
Me:" This job posting is for a senior programmer, I take it you're looking for juniors too ? I would happily take it, it's just I want a job to learn more things. Did you read my CV?"
R, annoyed: "Requirements for this position are quite clear, I believe. We are open to working with people with different experience level."
From there, she was pretty negative but I remained sympathetic and agreed to met with her boss next week. After all, maybe he has a position for me.
"Java and Javascript are similar like Car and Carpet are similar" -
When you're doing a generic programming course, and you're passing shit left and right with flying colors until you hit the one assignment where you have to write in human-speak...
-
I feel compelled to figure out how to use software in a gaming setting to teach skills like CS and Math. But do it in a way that is fun and not feeling like a "math game".
I want to spend more time learning about algorithms, architectures, design approaches, etc. Writing such a game would force me to understand what I present in a very intimate way.
I can see a way to create algos in game using very visual ways. Then allowing someone to make superstructures combining those algos to solve tasks.
I was inspired by how some algos require data to be sorted a certain way before starting. As the algo as a side effect resorts the data to know when it has completed. I realized if an algo is generic enough it can be combined just like functions or objects.
I also want to learn math better, especially in conjunction with code. So making a platform for learning these would be a lot of fun. I would definitely want both visual and textual interfaces to the code. I have to imagine a real programmer being frustrated with a visual interface unless it was really compelling.
I find it interesting that a lot of algos are represented visually when trying to show how it works. I realize some probably cannot be visualized so easy though.
I also want to use software like this to teach someone to think more deliberately and help people be more disciplined in their thinking. I know I could use this.
I have a secret goal of being able to use such software to help someone become a math/programming wizard. I don't know if this is achievable, but having exercises that help solidify root concepts in a fun way would be really useful IMO. -
Any good programming language with great generics support that is not dynamic ?
Rust generics sucks so much I puked 2 times.
Tried with swift and it looks great.
Golang doesn’t have them.
Java sucks.
Maybe I try julia if someone say it’s cool.
I want to implement some 2d vector algebra and simple physics engine.
I started by creating generic 2d vector and trying to create dot product from it.
I didn’t wanted to do it in swift but wasted 2 days trying to do it in rust vs 1 hour in swift including 49 minutes of installing swift tools.
Anyway anyone know performant language with good generics support, let me know in comments.39 -
!rant but I'd like some advice.
This summer I'm taking a brief course on programming, very generic and mostly just to get it officially on paper, and as of what I can tell a lot of it will be stuff I'm familiar with. Basic syntax, loops, logic, good practices, etc.
However, I get to choose the language I get to work in myself. I assume they have a set of the most commonly used ones (couldn't find a list of them though) and I was wondering if anyone had advice on which to pick?
I already have a base of decent JS and Python, but I feel like it might be good to pick something other than Python? Because even though I love it to bits, I do realize that it's not the optimal language in all situations. What I'm pondering is Java or one of the C-languages, but again, I'm not one of the pros here. Any recommendations?4 -
Top 12 C# Programming Tips & Tricks
Programming can be described as the process which leads a computing problem from its original formulation, to an executable computer program. This process involves activities such as developing understanding, analysis, generating algorithms, verification of essentials of algorithms - including their accuracy and resources utilization - and coding of algorithms in the proposed programming language. The source code can be written in one or more programming languages. The purpose of programming is to find a series of instructions that can automate solving of specific problems, or performing a particular task. Programming needs competence in various subjects including formal logic, understanding the application, and specialized algorithms.
1. Write Unit Test for Non-Public Methods
Many developers do not write unit test methods for non-public assemblies. This is because they are invisible to the test project. C# enables one to enhance visibility between the assembly internals and other assemblies. The trick is to include //Make the internals visible to the test assembly [assembly: InternalsVisibleTo("MyTestAssembly")] in the AssemblyInfo.cs file.
2. Tuples
Many developers build a POCO class in order to return multiple values from a method. Tuples are initiated in .NET Framework 4.0.
3. Do not bother with Temporary Collections, Use Yield instead
A temporary list that holds salvaged and returned items may be created when developers want to pick items from a collection.
In order to prevent the temporary collection from being used, developers can use yield. Yield gives out results according to the result set enumeration.
Developers also have the option of using LINQ.
4. Making a retirement announcement
Developers who own re-distributable components and probably want to detract a method in the near future, can embellish it with the outdated feature to connect it with the clients
[Obsolete("This method will be deprecated soon. You could use XYZ alternatively.")]
Upon compilation, a client gets a warning upon with the message. To fail a client build that is using the detracted method, pass the additional Boolean parameter as True.
[Obsolete("This method is deprecated. You could use XYZ alternatively.", true)]
5. Deferred Execution While Writing LINQ Queries
When a LINQ query is written in .NET, it can only perform the query when the LINQ result is approached. The occurrence of LINQ is known as deferred execution. Developers should understand that in every result set approach, the query gets executed over and over. In order to prevent a repetition of the execution, change the LINQ result to List after execution. Below is an example
public void MyComponentLegacyMethod(List<int> masterCollection)
6. Explicit keyword conversions for business entities
Utilize the explicit keyword to describe the alteration of one business entity to another. The alteration method is conjured once the alteration is applied in code
7. Absorbing the Exact Stack Trace
In the catch block of a C# program, if an exception is thrown as shown below and probably a fault has occurred in the method ConnectDatabase, the thrown exception stack trace only indicates the fault has happened in the method RunDataOperation
8. Enum Flags Attribute
Using flags attribute to decorate the enum in C# enables it as bit fields. This enables developers to collect the enum values. One can use the following C# code.
he output for this code will be “BlackMamba, CottonMouth, Wiper”. When the flags attribute is removed, the output will remain 14.
9. Implementing the Base Type for a Generic Type
When developers want to enforce the generic type provided in a generic class such that it will be able to inherit from a particular interface
10. Using Property as IEnumerable doesn’t make it Read-only
When an IEnumerable property gets exposed in a created class
This code modifies the list and gives it a new name. In order to avoid this, add AsReadOnly as opposed to AsEnumerable.
11. Data Type Conversion
More often than not, developers have to alter data types for different reasons. For example, converting a set value decimal variable to an int or Integer
Source: https://freelancer.com/community/...2 -
Maybe you people will like this story.
The past semester I studied Java in class. First time doing object oriented programming, I had an annoying teacher but got the hang of it. I still miss C from the last year.
As a final project we had to do any program and apply some stuff we saw in class (The program should have an array list, use interfaces, bla bla bla bery simple stuff). It also must have a complete documentation, a manual and a diary explaining what was developed every week. Bonus points if it was in a repository like GitLab.
I wanted to do an RPG game in a matrix, like a rougelike or an old FF game, that should be a map or two, a few monsters and items and that's it. Enough to show what can I do and to have enough excuses to apply everything that the teacher asked. I had a team with two friends who wanted to do the same.
After making accounts in three different pages that apparently would help us to be more organized (One to make charts and two task trackers) I lost all patience and made an account in GitLab, made the basic classes that we had defined in a chart, divided the tasks and put them in to do on GitLab and we started to work.
One of my companions caused a lot of problems. First, he didin't wanted to learn how to use GitLab (I simply asked them to do merge requests) and he insisted to use GitHub. Then he started to say that using the console version was even better (Pretty sure he said thet he never used Git, but maybe was gas poisoning). The GitLab repository never had a single commit to his name.
BUT WAIT IT GETS BETTER all the entire time, he was complaining about the graphical interface of the game, wanting to use some SDK for RPGs that he found. I told him that we will see that at the end, that first we should have all the mechanics done, test it in ASCII in the console and then, if we have time, we will put the visual interface, separated and optional from the main program to avoid problems.
After two weeks where he gave me very simple standard stuff late, half done and through Google Drive, I discovered he was most of the time working on... the graphical interface SDK! He took the job already done by me and the other guy and making a pretty hardcoded integration with the graphical interface and making everything that he tought it would be necesary. Soon enough the GitLab repository was totally outdated and completly useless. He had the totallity of the project in his half broken laptop, and sometimes he gave us a zip with all the code, outdated after a few minutes. Most of the stuff that I made was modified, a lot of the code was totally unknown to what it was and I had no idea even of how the folders were organised.
We had a month to finish it. I got totally disconected from the project and just hoped for the best, sometimes doing a handful of generic and adaptable lines of code for a specific thing (Funny enough, many core mechanics were nonexistent). The other guy managed to work more on the project, mostly fixing the mess that the guy did: apparently he didin't read the documentation of the SDK and just experimented and saw tutorials and tried to figure out how to do what he wanted.
Talking about documentation: we dont had yet. The code wasn't even commented propely. We did all that the last week and some stuff was finished the last night. The program apparently worked but I had no idea.
Thank God, the teacher just looked over everything and was very impressed by the working camera and the FF tiles. I don't think he saw the code or read too much of the documentation, much less when I directly wrote how I lost all access to the project.
I had a 10/10. I didin't complained. Most easy and annoying ten I ever had. I will never do a project with that guy. -
Hi devRant. Wanna rant with some shit about my company. First some good parts. I work in company with 600+ employees. It's one of the best companies in my region. They provide you with any kind of sweets(cookies, coffee, tea, etc), any hardware you need for your work (additional monitor, more ram, SSDs, processor, graphics card, whatever), just about everything you need to make your work faster/comfortable. Then, we have regular reviews (every 6 months), which rise salary from $0.75 to $1.5 per hour. (I live in poor country, where $15 per hour makes your more solvent then 70% of people, so having 100-200 bucks increase every half year is quite good rise).
The resulting increase of review depends on how team leader and project manager are satisfied with my work. And here starts the interesting (e.g. the shit comes in).
1) Seniority level in our company applies depending on the salary you have. That't right. It does not depend on your skill. Except the case when you're applying to vacancy. So if you tell that you're senior dev and prove it during interview, you'll have senior's salary. This is fine if you're just want money. But not if you love programming (as me) because of reasons bellow.
2) You don't need to have lots of programming experience to be a team leader. You can even be a junior team leader (but thanks god, on research projects only). You start from leading research projects and than move to billable if the director of research department is satisfied with your leading skills.
As a consequence our seniors are dumb AF. This pieces me off the most. Not all of them. A would say half of them are real pro guys, but the rest suck at programming (as for a senior). They are around junior/middle level.
I can understand if guy has $15 rate but still remains junior dev. That's fine. But hell no, he is treated as a middle, because his rate is $10+ now! And his mind has priority over middles and juniors. Not that junior have lof of good tougths but sometimes they do.
I'm lucky to work yet on small project so I'm the only dev, and so to speak TL for myself. But my colleague has this kind of senior team leader who is dumb AF. They work on ASP.NET Core project, the senior does not even know how to properly write generic constraints in C#. Seriously.
Just look at this shit. Instead of
MyClass<T> where T: class {}
he does this:
abstract class EnsureClass {}
MyClass<T> where T: EnsureClass {}
He writes empty abstract class, forces other classes to inherit it (thus, wasting the ability to inherit some useful class) just to ensure that generic T is a class. What thA FUCK is wrong with you dude?! You're a senior dev and you don't even know the language you're codding in.
And this shit is all over the company. Every monkey that had enough skill just to not be fired and enough patience to work 4-5 years becomes a senior! No-fucking-body cares and reviews your skill increase. The whole review is about department director asking TL and PM question like "how is this guy doing? is he OK or we should fire him?" That's the whole review. If TL does not like you, he can leave bad review and the company will set you on trial. If you confront TL during this period, pack your suitcase. Two cases of such shit I know personally. A good skilled guy could not just find common language with his TL and got fired. And the cherry on top of the case is that thay don't care about the fired dev's mind. They will only listen to reviewer. This is just absurd and just boils me down.
That's all i wanted to say. Thanks for your attention. -
With C++11, fell in love with std::enable_if and others in type_traits.
Lets you take generic programming to a whole new level. I never used it when this was part of boost thinking it didn't make as much sense. Now, I like to qualify my template definitions to be as restrictive as possible based on the expected usage.