Skip to content

Define data structure to store Majors / Minors / Tracks #2

Description

@darkliyznyanlin910

Improve Type Definitions for Major and Basket Data Structures

Current Issues

  1. Redundant Track Information

    • Track is defined separately from where it's used
    • Tracks are duplicated in both Major.availableTracks and global availableTracks
  2. Inconsistent Basket Definitions

    • Some basket names have duplicates ("Ethics And Social Responsibility")
    • Basket codes have overlaps (COR-OBHR appears twice)
    • No clear relationship between BasketType and BasketCode
  3. Type Safety Gaps

    • No validation that Major.baskets references valid BasketTypes
    • Track-specific baskets could be more strongly typed

Proposed Changes

  1. Consolidate Track Management
export const trackConfig = {
PD: { name: "Product Development", baskets: [...] },
DCS: { name: "Digital Cloud Solutions", baskets: [...] },
// ... other tracks with their specific configs
} as const;
export type Track = keyof typeof trackConfig;
  1. Improve Basket Type Safety
export type BasketDefinition = {
name: string;
code: BasketCode;
type: "core" | "track-specific" | "elective";
validTracks?: Track[];
};
export const basketDefinitions: Record<BasketType, BasketDefinition> = {
"Numeracy": {
name: "Numeracy",
code: "CORE",
type: "core"
},
// ... other baskets
};
  1. Stronger Major Type
export type Major = {
majorCode: MajorCode;
coreBasketsRequired: BasketType[];
trackRequirements: Record<Track, {
requiredBaskets: BasketType[];
electiveBaskets: BasketType[];
minimumCredits: number;
}>;
};

Benefits

  • Single source of truth for track configurations
  • Prevents duplicate/inconsistent basket definitions
  • Better type safety for track-specific requirements
  • Clearer relationship between baskets and their codes
  • Easier to maintain and extend

Implementation Notes

  • Will require refactoring existing code that uses these types
  • Should add validation utils to ensure data consistency
  • Consider adding TypeScript branded types for additional type safety

Metadata

Metadata

Labels

documentationImprovements or additions to documentationenhancementImprovement on existing features

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions