Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,155,742 members, 7,827,738 topics. Date: Tuesday, 14 May 2024 at 04:05 PM

Generics: Is This Possible In Your Language? - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Generics: Is This Possible In Your Language? (678 Views)

Is This Possible With C# Asp.net Mvc, And How? / All PHP Webmasters Please Is This Possible?? / What Is Concurrency And How Does Your Language Tackle It? (2) (3) (4)

(1) (Reply)

Generics: Is This Possible In Your Language? by kambo(m): 11:17pm On Oct 05, 2013
Most popular c-like languages have a mechanism for restricting the type of objects a container can accept. Generics. With inheritance restriction can b adjusted to classes of types , e.g a container that only accepts integers would reject doubles but if the type is set to any descendant of type number the restriction bcomes expanded.
The issue however is, restriction is tied to specific types or specific type classes. But in modelling real world situation the need for broadening the restriction parameters even further arises.
For example, say u want the container to accept a string an integer or a file. 3 types, any type of these 3 are acceptable else bounce them.
There's no generic shorthand for this. On d other hand issues like wats d maximum range of acceptable types that can b specified bcomes a problem e.g if a container is set to accept 1000 subtypes performance may degrade but in real life programming these kinda scenario occurs and this scenario breaks the oop philosophy of packing objects under a single ancestor so that they can b seamlessly processed by containers and other clients.
Writing boiler plate over loaded methods is tedious and wasteful of development time. Actually the core of the issue is modern languages cannot adhere strictly to one paradigm as counter scenarios will occur to continuously confound the solo philosophy the language is resting on. Functional languages dont suffer from this problem cuz theyre rougish and unstructured.
I.e un modular. Everything is a function or an argument to a function . Oop is more robust and introduce group thinking to software development (modularity thru classes, single inheritance to reduce needless complexity interfaces to augment shortfall of single direct inheritance and abstract classes, packages and namespaces for further grouping) but all the structure while satisfactory at times can seem as inflexible as an oak tree in a storm. A mechanism that gives the flexibility of a sappling without sacrificing the strenght of d oak is wat's needed and that may mean a number of cases deviating from single option solutions like is the case with the current generics philosophy in c like languages.

(1) (Reply)

Which Of These 2 Laptops Is Better? / A New Set Of Firefox Developer Tools Features / 7 Steps To Raising Seed Investment For Africa Focused Tech Startups

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 16
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.