Feature:
Ranking
Headline
Check salaries to follow ranks in company hierarchy
Description
Any company needs a pay structure (say, pay model). The present feature describes a constraint for a particular pay structure. Within each department, the salary of the department's manager is higher than all salaries of a department's immediate and sub-immediate employees. The constraint needs to be checked or enforced along construction and the modification of company data. Clearly, this is just one possible and arguably rather rigid and unrealistic pay structure.
Motivation
Conceptually, the feature imposes a global invariant on company data. Straightforward expressiveness of type systems is not sufficient to model the constraint. Simple contracts in the sense of pre- and post-conditions or class invariants on local state are also not sufficient; we need to allow for traversal of object graphs. Of course, the constraint can be expressed more or less easily as a recursive computation, very much like a query over the hierarchical structure of companies; see Feature:Depth.
Illustration
The feature is illustrated with a Function in Language:Haskell that works on top of appropriate algebraic data types for company data; the function recurses into company data in a straightforward manner and it counts departments along the way:
align :: Company -> Bool
align (Company ds) = and (map (align' Nothing) ds)
where
align' :: Maybe Float -> Department -> Bool
align' v (Department m ds es)
= maybe True (>getSalary m) v
&& and (map (align' (Just (getSalary m))) ds)
&& and (map ((<getSalary m) . getSalary) es)
getSalary :: Employee -> Float
getSalary (Employee s) = s
Further, in some code locations the constraint needs to be invoked. Here is some snippet that shows how the constraint is invoked past cutting salaries:
main = do
... -- code omitted
-- Cut all salaries
let company' = cut company
-- Test that salaries align with hierarchy
if not (align company')
then error "constraint violated"
else return ()
The snippet originates from Contribution:haskellComposition.
Relationships
- The present feature can only usefully instantiated on top of Feature:Hierarchical_company, as it assumes nesting of departments for non-trivial results.
- A straightforward scenario for testing the present feature would check the constraint past cutting salaries according to Feature:Cut.
Guidelines
- The name of a constrain for checking alignment of salaries with hierarchical company structure should involve the term "align".
- A suitable demonstration of the feature's implementation should show the constraint is to be invoked (explicitly or implicitly) past construction or modification of company data.
There are no revisions for this page.
User contributions
User edits
Syntax for editing wiki
For you are available next options:will make text bold.
will make text italic.
will make text underlined.
will make text striked.
will allow you to paste code headline into the page.
will allow you to link into the page.
will allow you to paste code with syntax highlight into the page. You will need to define used programming language.
will allow you to paste image into the page.
is list with bullets.
is list with numbers.
will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.
will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.
will allow your to insert code snippets from @worker.
Syntax for editing wiki
For you are available next options:will make text bold.
will make text italic.
will make text underlined.
will make text striked.
will allow you to paste code headline into the page.
will allow you to link into the page.
will allow you to paste code with syntax highlight into the page. You will need to define used programming language.
will allow you to paste image into the page.
is list with bullets.
is list with numbers.
will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.
will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.
will allow your to insert code snippets from @worker.