SFDesignPrinciple.sleela
socialism-and-final/SFDesignPrinciple.sleela · 130 line(s) · sleela
<< socialism-and-final/SFDesignPrinciple.sleela
SLeeLa Standard Library Definition.
Definition: An elegant, named design principle a creator can reason with. >>
#sleela 2.1
<< Family: socialism-and-final. SFDesignPrinciple is one well-named rule of good
visual/structural design, expressed so a creator can render excellent work by
reasoning with it rather than guessing. It carries the principle name, a short
statement, a worked guideline, and a 1..10 strength a renderer can weight.
It asserts no taste as absolute. A principle is a tool: it tells you what a
choice optimizes for, and names the failure at each extreme, so the creator
keeps the symmetry (see the 1491 modifier) rather than tilting the work.
Typical use:
SFDesignPrinciple p = new SFDesignPrinciple();
p.define("Contrast", "Difference creates hierarchy and draws the eye.", 8);
print(p.render()); >>
class SFDesignPrinciple {
< the short, memorable name of the principle >
String title;
< one-sentence statement of what it optimizes for >
String statement;
< the failure when the principle is pushed too far >
String excess;
< the failure when the principle is ignored >
String absence;
< 1..10 how strongly a renderer should weight it by default >
int strength;
< ---- lifecycle ------------------------------------------------------ >
void create() {
title = "Unnamed";
statement = "";
excess = "";
absence = "";
strength = 5;
}
< Define the principle in one call. Strength is clamped to 1..10. >
void define(String t, String s, int weight) {
title = t;
statement = s;
strength = clampStrength(weight);
}
< Name the two failure modes, so the creator can keep the balance. >
void bound(String tooMuch, String tooLittle) {
excess = tooMuch;
absence = tooLittle;
}
< ---- reasoning helpers ---------------------------------------------- >
< A renderer weight in [0.0..1.0] terms, scaled x100 as an int (no floats). >
int weightPercent() {
return strength * 10;
}
< True when this principle should dominate a conflicting weaker one. >
boolean outranks(int otherStrength) {
return strength > clampStrength(otherStrength);
}
< A readable one-line rendering of the principle. >
String render() {
return title + " [" + toStr(strength) + "/10]: " + statement;
}
< The balance note: both failure modes, so neither extreme is chosen blindly. >
String balance() {
return title + " holds between two failures -- too much: " + excess
+ " ; too little: " + absence + ".";
}
< ---- internals ------------------------------------------------------ >
int clampStrength(int v) {
int r = v;
if (r < 1) { r = 1; }
if (r > 10) { r = 10; }
return r;
}
String toStr(int v) {
return "" + v;
}
< ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
< Eleven catalogued attributes with getter/setter pairs. Values are faithful >
< to the real origin of the design tradition this class draws on; where a >
< principle has no single owner, the record says so rather than inventing one. >
String metaVersion = "1.0.0";
int metaId = 1;
String metaAuthor = "none (design principles are a shared craft tradition)";
String metaDate = "2026-10-26";
String metaCopyright = "none (public craft knowledge)";
String metaTrademark = "none";
String metaCorporation = "none";
String metaOrigin = "International";
String metaBirthDate = "unknown";
< maturity/robustness on a 1..10 scale >
int metaScienceRating = 7;
String metaNationalSchedule = "none";
String getMetaVersion() { return metaVersion; }
void setMetaVersion(String v) { metaVersion = v; }
int getMetaId() { return metaId; }
void setMetaId(int v) { metaId = v; }
String getAuthor() { return metaAuthor; }
void setAuthor(String v) { metaAuthor = v; }
String getDate() { return metaDate; }
void setDate(String v) { metaDate = v; }
String getCopyright() { return metaCopyright; }
void setCopyright(String v) { metaCopyright = v; }
String getTrademark() { return metaTrademark; }
void setTrademark(String v) { metaTrademark = v; }
String getCorporation() { return metaCorporation; }
void setCorporation(String v) { metaCorporation = v; }
String getOrigin() { return metaOrigin; }
void setOrigin(String v) { metaOrigin = v; }
String getBirthDate() { return metaBirthDate; }
void setBirthDate(String v) { metaBirthDate = v; }
int getScienceRating() { return metaScienceRating; }
void setScienceRating(int v) { metaScienceRating = v; }
String getNationalSchedule() { return metaNationalSchedule; }
void setNationalSchedule(String v) { metaNationalSchedule = v; }
}