Originally posted by mudskipper
View Post
- Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
- Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Reply to: Half baked ideas
Collapse
You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:
- You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
- You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
- If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.
Logging in...
Previously on "Half baked ideas"
Collapse
-
OK
I have an interface Wotsit<T> { T doStuff(); }
I want a factory method that returns a Wotsit for different types of T. It needs to support multiple types, lookup a wotsit based on the return type, and support runtime registration of new types and associated wotsits, so the factory method needs to take the return type as a parameter. I can do this as long as T isn't a generic type. Unfortunately I need it to support generic types.
e.g. I can do this
Wotsit<Blah> myWotsit = WotsitFactory.getWotsit(Blah.class);
Blah result = myWotsit.doStuff();
but this doesn't work
Wotsit<List<Blah>> myWotsit = WotsitFactory.getWotsit(List<Blah>.class);
List<Blah> result = myWotsit.doStuff();
for (Blah blah : result) {
....
Yes, I know I can use Object, but I don't want to, that defeats the point of using generics in the first place. I might as well be using ******* void *
Can C# do this?
What I can do is create a non generic class that implements List<Blah> and then use something like
Wotsit<? extends List<Blah>> myWotsit = WotsitFactory.getWotsit(BlahList.class);
What a PITA.
Especially when you have List<BlahList> to deal with. One BlahListListListListList coming up.Last edited by doodab; 15 July 2013, 21:50.
Leave a comment:
-
c# var keyword equivalent in java? - Stack OverflowOriginally posted by d000hg View PostI meant c#'s var...
Edit: Or wot 'e sed.Originally posted by eek View PostJava really doesn't do implicit types. The reason I added it was to show one of the advantages of C# in the fact it can handle implicit types and conversions without pain.
Personally I hate them but then again I don't like Linq that much full stop. I'm very old school give me stored procedures any day.
Leave a comment:
-
Java really doesn't do implicit types. The reason I added it was to show one of the advantages of C# in the fact it can handle implicit types and conversions without pain.Originally posted by mudskipper View PostI fear we've missed eek's point, but don't know enough of Java to be sure.
Personally I hate them but then again I don't like Linq that much full stop. I'm very old school give me stored procedures any day.
Leave a comment:
-
I fear we've missed eek's point, but don't know enough of Java to be sure.Originally posted by d000hg View PostNah I don't like all the non-typed stuff either. It's a proper language, not bloody JS.
Leave a comment:
-
Nah I don't like all the non-typed stuff either. It's a proper language, not bloody JS.
Leave a comment:
-
I only use var when it's too bloody complicated to work out what I'm getting back (Linq). Mebbe I should be more liberal.Originally posted by eek View Postsurely that would be
var loads = new List<StuffThatCSharpDoesBetterThanJava>();
Although personally I curse resharper every time it suggests it.
Leave a comment:
-
surely that would beOriginally posted by mudskipper View PostList<StuffThatCSharpDoesBetterThanJava> loads = new List<StuffThatCSharpDoesBetterThanJava>();
var loads = new List<StuffThatCSharpDoesBetterThanJava>();
Although personally I curse resharper every time it suggests it.
Leave a comment:
-
List<StuffThatCSharpDoesBetterThanJava> loads = new List<StuffThatCSharpDoesBetterThanJava>();Originally posted by d000hg View PostIndeed. C# on the other hand does it very nicely.
Leave a comment:
-
Half baked ideas
Don't you just love them.
Java generics. Oh dear.Tags: None
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers
Contractor Services
CUK News
- JSL rules ‘are HMRC’s way to make contractor umbrella company clients give a sh*t where their money goes’ Today 07:42
- Contractors warned over HMRC charging £3.5 billion too much Feb 6 03:18
- Statutory Sick Pay (SSP) for umbrella company contractors: an April 2026 explainer Feb 5 07:19
- IR35: IT contractors ‘most concerned about off-payroll working rules’ Feb 4 07:11
- Labour’s near-silence on its employment status shakeup is telling, and disappointing Feb 3 07:47
- Business expenses: What IT contractors can and cannot claim from HMRC Jan 30 08:44
- April’s umbrella PAYE risk: how contractors’ end-clients are prepping Jan 29 05:45
- How EV tax changes of 2025-2028 add up for contractor limited company directors Jan 28 08:11
- Under the terms he was shackled by, Ray McCann’s Loan Charge Review probably is a fair resolution Jan 27 08:41
- Contractors, a £25million crackdown on rogue company directors is coming Jan 26 05:02


Leave a comment: