- 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!
I think I am going to cry
Collapse
X
Collapse
-
-
So lets say your screen has ten buttons (Observables). That means you need to have either 10 Observers or 1 observer which will receive some kind of button ID and process the appropriate button click accordingly?Comment
-
You could have 63 observers if you need. Humour me by reading up on the observer pattern.
Sent from my iMinion using TapatalkKnock first as I might be balancing my chakras.Comment
-
But... this is the bit i'm trying to get at now - So if I need to write 63 observers without using anonymous classes, and bearing in mind that you saidWhy does needing a named function immediately say to you you need to create a class?Comment
-
Knock first as I might be balancing my chakras.Comment
-
Comment
-
Knock first as I might be balancing my chakras.Comment
-
Seriously?, The observer pattern is massive overkill for creating button event handlers, the language has much better support for this use case, called anonymous inner classesComment
-
Knock first as I might be balancing my chakras.Comment
-
I already asked: you have ten buttons that are observable. That's ten Observables. You then need Observers registered for each; So lets say either 1 registered with all ten, or 10 different observers - 1 registered with each Observable.
To this you agreed. Fine so far.
So then I say so if you had 63 buttons and 63 observers, as you suggested, then you need to code 63 methods to implement the Observer interface for each of the 63 buttons.
You suggested that we don't need to create new concrete classes for each, so we can either
A) have 63 existing objects that do whatever it is that they do AND also handle a particular button click. Or
B) have 1 single existing object with the capability to identify which particular button has notified it that it got clicked.
This is almost what you already agreed to with 10 buttons. We've just upped it to 63 and added the condition that we won't implement new handler/Observer classes.
I then implied that it might be a tall order to find 63 already existing classes that do whatever it is that they do, which ALSO can then handle a particular button click logic without violating lots of good SOLID principles.
At which point you just say that I don't understand the Observer pattern.Comment
- 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
- Streamline Your Retirement with iSIPP: A Solution for Contractor Pensions Sep 1 09:13
- Making the most of pension lump sums: overview for contractors Sep 1 08:36
- Umbrella company tribunal cases are opening up; are your wages subject to unlawful deductions, too? Aug 31 08:38
- Contractors, relabelling 'labour' as 'services' to appear 'fully contracted out' won't dupe IR35 inspectors Aug 31 08:30
- How often does HMRC check tax returns? Aug 30 08:27
- Work-life balance as an IT contractor: 5 top tips from a tech recruiter Aug 30 08:20
- Autumn Statement 2023 tipped to prioritise mental health, in a boost for UK workplaces Aug 29 08:33
- Final reminder for contractors to respond to the umbrella consultation (closing today) Aug 29 08:09
- Top 5 most in demand cyber security contract roles Aug 25 08:38
- Changes to the right to request flexible working are incoming, but how will contractors be affected? Aug 24 08:25
Comment