the return of chef (troc) a programming language for cooking recipes and nutrition analysis
DESCRIPTION
The Return of Chef (TROC) A Programming Language for Cooking Recipes and Nutrition Analysis. TROC Project Team. Jia Chen – Language Architect Jeff Hull – Tester and Validator Kuang Shen – System Integrator Yiping Xu – Tools Guru. The Purpose of TROC. Healthy Diet Lifestyle - PowerPoint PPT PresentationTRANSCRIPT
The Return of Chef (TROC)
A Programming Language for Cooking Recipes and Nutrition Analysis
TROC Project Team
Jia Chen – Language ArchitectJia Chen – Language Architect Jeff Hull – Tester and ValidatorJeff Hull – Tester and Validator Kuang Shen – System IntegratorKuang Shen – System Integrator Yiping Xu – Tools GuruYiping Xu – Tools Guru
The Purpose of TROC
Healthy Diet Healthy Diet Lifestyle Lifestylevarious diet services found on/offlinevarious diet services found on/offline
which theory do I follow??which theory do I follow??
how to know the healthiness of my own how to know the healthiness of my own dietdiet
hard for amateur to calculate the hard for amateur to calculate the nutrition factsnutrition facts
The Purpose of TROC
Then comes TROC!Then comes TROC!{{
11 create your own recipes for daily diet;create your own recipes for daily diet;
22 have nutrition facts auto-calculated; have nutrition facts auto-calculated;
33 adjust recipe to “healthize” diet; adjust recipe to “healthize” diet;
44 recalculate, if still unsatisfied GOTO line 3; recalculate, if still unsatisfied GOTO line 3;
55 cook; cook;
66 inject food; inject food;
}}
Design Principles
Syntax: Syntax: - Close to recipe convention - Close to recipe convention
|- Less ambiguous|- Less ambiguous
|- Smooth learning curve|- Smooth learning curve20-Minute Beef Stew
3 pounds boneless beef, cut into cubes
1/3 cup flour
1 ½ cups wine
3 tablespoons oliveoil
1 onion, chopped
2 carrots, cut into pieces
1 pound potatoes, cut into pieces
Salt and ground pepper
Coat beef with flour, salt and pepper;
Warm oliveoil with pressure cooker for 3 minutes;
Add wine,beef,onion,potato and carrot into the cooker;
Cook on “high” for 20 minutes;
Serve.
Dish 20_Minute_BeefStew{beefToBeStewed: 3 lb BonelessBeef;flour: 1/3 cup Flour;salt: 2 g Salt;pepper: 1 g GroundPepper;oliveOil: 3 teaspoon OliveOilwine: 1.5 cup RedWine;onion: 1 unit Onion;carrot: 2 unit Carrot;potato: 0.5 lb Potato;
cut beefToBeStewed into cubes;chop onion;cut [carrot,potato] into pieces;coat beefToBeStewed with [salt, pepper, flour];cook oliveOil with PressureCooker for 3 minute;cook [beefToBeStewed, onionToBeChopped, garlic, carrot, potato, wine, oliveOil] with PressureCooker mode HIGH for 20 minute;
}
Design Principles
Semantics:- Strongly TypedSemantics:- Strongly Typede.g. Rule: Cook Ingredient with Cookwaree.g. Rule: Cook Ingredient with Cookware
Cook Beef with PressureCooker Cook Beef with PressureCooker Cook Beef with MixingBowlCook Beef with MixingBowl
- Static Typing- Static Typing - Object inheritance- Object inheritance
- Integrated Metric - Integrated Metric SystemSystem
e.g. e.g. olvOil: 3 olvOil: 3 teaspoonteaspoon OliveOil; OliveOil;equivalent to 0.5 oz OliveOilequivalent to 0.5 oz OliveOilTranslation done at compile timeTranslation done at compile time
Runtime
Runtime Routine CallsRuntime Routine Calls-- Program written in TROC is translated into java code Program written in TROC is translated into java code
which call functions in TROC run-time API which call functions in TROC run-time API
Nutrition Facts CalculationNutrition Facts Calculation-- Embedded in the TROC API functions, based on the Embedded in the TROC API functions, based on the
ingredients, tools and operations involved ingredients, tools and operations involved
- Formula based on the online authentic nutrient - Formula based on the online authentic nutrient database database created and maintained by created and maintained by Nutrition.govNutrition.gov
Execution Output
20-minute Beef Stew Nutrition Facts (per serving)
0%
10%
20%
30%
40%
50%
60%
70%
80%
90%
Carbohydrates(22g)
Fat (12g) Protein (11g) Calcium (1.2g) Vitamins A(4.4g)
Vitamins C(0.4g)
Sodium (0.9g)
nutritions
dai
ly d
ose
per
cen
tag
e
Major Nutrition Precentage
Carbohydrates
Fat
Protein
Calcium
Vitamins A
Vitamins C
Sodium
Using external library to output result from Microsoft ExcelUsing external library to output result from Microsoft Excel
Input_file.trocJLex:
Lexer
Symbol Table
CUP:Parser
Semantic Analyzer
Type Checking
Exception Handling
Troc API (written in
JAVA)
Intermediate Code Generator
Java Compiler JVM Output
Runtime Environment
Runtime Environment
Troc Type DefinitionTroc Type Definition
Cook Operation APICook Operation API
Troc Type Hierarchy
Ingredient
Fruit
ChickenBeef Pork
CondimentSeafood VegetableMeat
……
……CookWare
Inheritance
If there is something that is not one If there is something that is not one of the food type we already have,of the food type we already have,
Inheritance!
Grammar: Mushroom is a kind of Vegetable with white color, 10 Juiciness…...
M1 : 20 g Mushroom;
Cook Operation API
Cut (IngredientType beingCutObject, Cut (IngredientType beingCutObject, ToolType toolID, int Weight,)ToolType toolID, int Weight,)
Cook(IngredientType Cook(IngredientType beingCookedObject,beingCookedObject,ContainerTyper , int Weight)ContainerTyper , int Weight)
Other cook operations that we support: Other cook operations that we support: Place, Crush, Marinate, Coat,…Place, Crush, Marinate, Coat,…
Runtime API Functionality
Calculate the nutritionCalculate the nutrition Based on the formulaBased on the formula
Render the chartRender the chart
Runtime Output
0
5
10
15
20
25
30
35
0 30 60 90
Ti me
Vi tami nAVi tami nCVi tami nB
0200400600800
1000120014001600
0 30 60 90
Ti me
Cal or i ePertai n
Test Plan
Smoke TestSmoke Test Begin by testing the high level featuresBegin by testing the high level features
Unit TestingUnit Testing Create test cases for every function in APICreate test cases for every function in API black-box approachblack-box approach compare the actual results with expected resultscompare the actual results with expected results
Regression TestingRegression Testing Maintained a test file, where for every new Maintained a test file, where for every new
grammar construct added, we will run the test grammar construct added, we will run the test file to maintain program consistencyfile to maintain program consistency
Tested for:Tested for: Logical errors/inconsistenciesLogical errors/inconsistencies Syntax inconsistenciesSyntax inconsistencies Overall success of instructionsOverall success of instructions
Conclusions
What We LearnedWhat We Learned Aside from some healthy Aside from some healthy
recipes…recipes… Gained Valuable Group Gained Valuable Group
work experiencework experience How to cope when a team How to cope when a team
member quitsmember quits The ins and outs of The ins and outs of
designing a Languagedesigning a Language How to limit the scope and How to limit the scope and
complexity of your projectcomplexity of your project
Why Use our Language?
The benefits of healthy eating are The benefits of healthy eating are too numerous to name. Our too numerous to name. Our language can help you cook and language can help you cook and eat healthier.eat healthier.
Questions?