|
此文章由 DDD888 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 DDD888 所有!转贴必须注明作者、出处和本声明,并保持内容完整
本帖最后由 DDD888 于 2022-3-16 13:57 编辑
涮涮面试题和做个开源项目,显然是不在一个层次上的啦,一个是纸上谈兵啦,一个是拿起斧头去砍树。根据我27年开发软件的经验,做个开源项目其实就是做个项目,相当于综合能力的学习,应用和提高啦,不要小看在做项目时碰到的一个问题,在不懂的时候,有些问题是不能用正确的关键词在google上搜索找到答案的,当然啦,成为专家后,一些问题一看立即就知道答案了,那是在经过无数次解决实际问题后积累的啦,不是刷题能积累的啦,实际工作,就是不断写程序,做项目,和自己做项目的区别,是老板出钱提高你机会,自己做项目是没老板出钱啦,还有就是给公司打工,老板给你项目提要求,自己做项目是你自己给自己提要求
例如我在学习电子,看到别人已有网页和应用程序来计算lc频率的关系,我确实可以直接来用,但为了给自己经验,我就自己写个reactjs项目来计算,下面是一部分用typescript,mobx写的代码,以免被人说吹牛啦,大家看了感觉不好的,可以指点我啊
import { makeObservable, observable, action, computed } from "mobx"
import SelectOption from "./SelectOption"
class Values {
time: number
timeUnit: string
timeUnits: readonly SelectOption[]
frequencyDisplayUnit: string
frequencyDisplayUnits: readonly SelectOption[]
capacitor: number
capacitorUnit: string
capacitorUnits: readonly SelectOption[]
constructor() {
makeObservable(this, {
time: observable,
timeUnit: observable,
timeUnits: observable,
capacitor: observable,
capacitorUnit: observable,
capacitorUnits: observable,
frequencyDisplayUnit: observable,
frequencyDisplayUnits: observable,
Inductance: computed,
InductanceDisplay: computed,
frequency: computed,
frequencyDisplay: computed,
timeUnitToNumber: computed,
capacitorUnitToNumber: computed,
setTime: action("setTime"),
setTimeUnit: action("setTimeUnit"),
setCapacitor: action("setCapacitor"),
setCapacitorUnit: action("setCapacitorUnit"),
setFrequencyDisplayUnit: action("setFrequencyDisplayUnit"),
})
this.time = 60
this.timeUnit = "ns"
this.timeUnits = this.stringArrayToReadonlySelectOption(["s", "ms", "µs", "ns", "ps"])
this.capacitor = 22.99
this.capacitorUnit = "uf"
this.capacitorUnits = this.stringArrayToReadonlySelectOption(["f", "mf", "µf", "nf", "pf"])
this.frequencyDisplayUnit = "khz"
this.frequencyDisplayUnits = this.stringArrayToReadonlySelectOption(["hz", "khz", "mhz", "ghz"])
}
stringArrayToReadonlySelectOption(items: string[]): readonly SelectOption[] {
return items.map((item: string) => {
return {
value: item,
label: item
}
})
}
setTime(value: number): void {
this.time = value
}
setTimeUnit(value?: string): void {
if (undefined === value) {
return
}
this.timeUnit = value
}
setCapacitorUnit(value?: string): void {
if (undefined === value) {
return
}
this.capacitorUnit = value
}
setCapacitor(value: number): void {
this.capacitor = value
}
setFrequencyDisplayUnit(value?: string): void {
if (undefined === value) {
return
}
this.frequencyDisplayUnit = value
}
get capacitorUnitToNumber(): number {
switch (this.capacitorUnit) {
case "f":
return 1
case "mf":
return Math.pow(0.1, 3)
case "µf":
return Math.pow(0.1, 6)
case "nf":
return Math.pow(0.1, 9)
case "pf":
return Math.pow(0.1, 12)
}
return 1
}
get Inductance(): number {
let real_cap = this.capacitor * this.capacitorUnitToNumber
return 1 / (Math.pow(2 * Math.PI * this.frequency, 2) * real_cap)
}
get timeUnitToNumber(): number {
switch (this.timeUnit) {
case "s":
return 1
case "ms":
return 3
case "µs":
return 6
case "ns":
return 9
case "ps":
return 12
}
return 1
}
get frequency(): number {
let unit = this.timeUnitToNumber
if (unit === 1) {
return 1 / this.time
}
let real_time = this.time * Math.pow(0.1, unit)
return 1 / real_time
}
get frequencyDisplay(): string {
let value = this.frequency;
return (value / this.frequencyDisplayUnitToNumber).toFixed(1)
}
get frequencyDisplayUnitToNumber(): number {
switch (this.frequencyDisplayUnit) {
case "hz":
return 1
case "khz":
return Math.pow(10, 3)
case "mhz":
return Math.pow(10, 6)
case "ghz":
return Math.pow(10, 9)
}
return 1
}
get InductanceDisplay(): string {
let l_value = this.Inductance
if (l_value < Math.pow(10, -9)) {
let value = l_value * Math.pow(10, 12)
return value.toFixed(1) + "ph"
}
if (l_value < Math.pow(10, -6)) {
let value = l_value * Math.pow(10, 9)
return value.toFixed(1) + "nh"
}
if (l_value < Math.pow(10, -3)) {
let value = l_value * Math.pow(10, 6)
return value.toFixed(1) + "uh"
}
if (l_value < 1) {
let value = l_value * Math.pow(10, 3)
return value.toFixed(1) + "mh"
}
return l_value.toFixed(1) + "h"
}
}
export default Values
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
评分
-
查看全部评分
|